
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Android常用代码 · Aivin开发笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Aivin">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../源码阅读/源码阅读配置.html" />
    
    
    <link rel="prev" href="开源软件.html" />
    

    
        <link rel="shortcut icon" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    首页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="常用网站.html">
            
                <a href="常用网站.html">
            
                    
                    常用网站
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../常用软件/常用软件和框架.html">
            
                <a href="../常用软件/常用软件和框架.html">
            
                    
                    常用软件和框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="开发规范.html">
            
                <a href="开发规范.html">
            
                    
                    开发规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="开源软件.html">
            
                <a href="开源软件.html">
            
                    
                    开源软件和框架
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.6" data-path="Android常用代码.html">
            
                <a href="Android常用代码.html">
            
                    
                    Android常用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../源码阅读/源码阅读配置.html">
            
                <a href="../源码阅读/源码阅读配置.html">
            
                    
                    源码阅读
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../源码阅读/其他框架源码.html">
            
                <a href="../源码阅读/其他框架源码.html">
            
                    
                    其他框架源码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../产品经理/产品经理.html">
            
                <a href="../产品经理/产品经理.html">
            
                    
                    产品经理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../设计模式/设计模式.html">
            
                <a href="../设计模式/设计模式.html">
            
                    
                    设计模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../设计模式/设计模式.html">
            
                <a href="../设计模式/设计模式.html">
            
                    
                    设计模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../设计模式/模式详解.html">
            
                <a href="../设计模式/模式详解.html">
            
                    
                    模式详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../设计模式/mvc等.html">
            
                <a href="../设计模式/mvc等.html">
            
                    
                    mvc等
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../数据结构/常用数据结构.html">
            
                <a href="../数据结构/常用数据结构.html">
            
                    
                    基本算法
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../数据结构/常用数据结构.html">
            
                <a href="../数据结构/常用数据结构.html">
            
                    
                    常用数据结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../常用算法/算法术语.html">
            
                <a href="../常用算法/算法术语.html">
            
                    
                    算法术语
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../常用算法/排序算法.html">
            
                <a href="../常用算法/排序算法.html">
            
                    
                    排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../常用算法/查找算法.html">
            
                <a href="../常用算法/查找算法.html">
            
                    
                    查找算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../常用算法/大数相加.html">
            
                <a href="../常用算法/大数相加.html">
            
                    
                    大数相加
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" data-path="../常用算法/集合的所有子集.html">
            
                <a href="../常用算法/集合的所有子集.html">
            
                    
                    获得集合的所有子集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.7" data-path="../常用算法/扫描线种子填充算法.html">
            
                <a href="../常用算法/扫描线种子填充算法.html">
            
                    
                    扫描线种子填充算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.8" data-path="../常用算法/其他算法.html">
            
                <a href="../常用算法/其他算法.html">
            
                    
                    其他算法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../java基础/原码补码反码.html">
            
                <a href="../java基础/原码补码反码.html">
            
                    
                    Java部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../java基础/原码补码反码.html">
            
                <a href="../java基础/原码补码反码.html">
            
                    
                    原码补码反码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../java基础/java常用代码.html">
            
                <a href="../java基础/java常用代码.html">
            
                    
                    java常用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../java基础/JVM详解.html">
            
                <a href="../java基础/JVM详解.html">
            
                    
                    JVM详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../java基础/类加载机制.html">
            
                <a href="../java基础/类加载机制.html">
            
                    
                    类加载机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="../java基础/内存模型.html">
            
                <a href="../java基础/内存模型.html">
            
                    
                    内存模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.6" data-path="../java基础/GC机制.html">
            
                <a href="../java基础/GC机制.html">
            
                    
                    GC机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.7" data-path="../java基础/对象内存布局.html">
            
                <a href="../java基础/对象内存布局.html">
            
                    
                    对象内存布局
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.8" data-path="../java基础/继承多态.html">
            
                <a href="../java基础/继承多态.html">
            
                    
                    继承和多态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.9" data-path="../java基础/相等判断.html">
            
                <a href="../java基础/相等判断.html">
            
                    
                    相等判断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.10" data-path="../java基础/Java容器类.html">
            
                <a href="../java基础/Java容器类.html">
            
                    
                    Java容器类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.11" data-path="../java基础/Java枚举.html">
            
                <a href="../java基础/Java枚举.html">
            
                    
                    Java枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.12" data-path="../java基础/自定义异常.html">
            
                <a href="../java基础/自定义异常.html">
            
                    
                    自定义异常
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.13" data-path="../java基础/深度拷贝.html">
            
                <a href="../java基础/深度拷贝.html">
            
                    
                    深度拷贝
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.14" data-path="../java基础/泛型详解.html">
            
                <a href="../java基础/泛型详解.html">
            
                    
                    泛型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.15" data-path="../java基础/线程详解.html">
            
                <a href="../java基础/线程详解.html">
            
                    
                    线程详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.16" data-path="../java基础/java注解.html">
            
                <a href="../java基础/java注解.html">
            
                    
                    注解详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.17" data-path="../java基础/数据解析.html">
            
                <a href="../java基础/数据解析.html">
            
                    
                    数据解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.18" data-path="../java基础/java8新特性.html">
            
                <a href="../java基础/java8新特性.html">
            
                    
                    Java8新特性
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../android基础/android零散知识.html">
            
                <a href="../android基础/android零散知识.html">
            
                    
                    Android部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../android基础/基础控件使用.html">
            
                <a href="../android基础/基础控件使用.html">
            
                    
                    基础控件使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../android基础/android零散知识.html">
            
                <a href="../android基础/android零散知识.html">
            
                    
                    Android零散知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../android基础/android坐标体系.html">
            
                <a href="../android基础/android坐标体系.html">
            
                    
                    Android坐标体系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.4" data-path="../android基础/APP的启动流程.html">
            
                <a href="../android基础/APP的启动流程.html">
            
                    
                    APP启动流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.5" data-path="../android基础/View加载流程.html">
            
                <a href="../android基础/View加载流程.html">
            
                    
                    View加载流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.6" data-path="../android基础/事件分发机制.html">
            
                <a href="../android基础/事件分发机制.html">
            
                    
                    事件分发机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.7" data-path="../android基础/控件绘制流程.html">
            
                <a href="../android基础/控件绘制流程.html">
            
                    
                    控件绘制流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.8" data-path="../android基础/常用shape.html">
            
                <a href="../android基础/常用shape.html">
            
                    
                    常用shape
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.9" data-path="../android基础/进程通信.html">
            
                <a href="../android基础/进程通信.html">
            
                    
                    进程通信
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.10" data-path="../通信方式/通信方式详解.html">
            
                <a href="../通信方式/通信方式详解.html">
            
                    
                    通信方式详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.11" data-path="../android基础/Binder详解.html">
            
                <a href="../android基础/Binder详解.html">
            
                    
                    Binder详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.12" data-path="../android基础/Handler详解.html">
            
                <a href="../android基础/Handler详解.html">
            
                    
                    Handle详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.13" data-path="../android基础/Fragment详解.html">
            
                <a href="../android基础/Fragment详解.html">
            
                    
                    Fragment详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.14" data-path="../android基础/Activity详解.html">
            
                <a href="../android基础/Activity详解.html">
            
                    
                    Activity详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.15" data-path="../android基础/BroadcastReceiver.html">
            
                <a href="../android基础/BroadcastReceiver.html">
            
                    
                    BroadcastReceiver详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.16" data-path="../android基础/Service服务.html">
            
                <a href="../android基础/Service服务.html">
            
                    
                    Service详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.17" data-path="../android基础/动画详解.html">
            
                <a href="../android基础/动画详解.html">
            
                    
                    动画详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.18" data-path="../android基础/屏幕刷新机制.html">
            
                <a href="../android基础/屏幕刷新机制.html">
            
                    
                    屏幕刷新机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.19" data-path="../android基础/屏幕适配.html">
            
                <a href="../android基础/屏幕适配.html">
            
                    
                    屏幕适配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.20" data-path="../android基础/图片加载详解.html">
            
                <a href="../android基础/图片加载详解.html">
            
                    
                    图片加载详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.21" data-path="../android基础/WebView详解.html">
            
                <a href="../android基础/WebView详解.html">
            
                    
                    WebView详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.22" data-path="../android基础/沉浸式.html">
            
                <a href="../android基础/沉浸式.html">
            
                    
                    沉浸式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.23" data-path="../android基础/相机模块.html">
            
                <a href="../android基础/相机模块.html">
            
                    
                    相机模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.24" data-path="../android基础/地图模块.html">
            
                <a href="../android基础/地图模块.html">
            
                    
                    地图模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.25" data-path="../android基础/Androidstudio插件开发.html">
            
                <a href="../android基础/Androidstudio插件开发.html">
            
                    
                    Androidstudio插件开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.26" data-path="../android基础/Apk插件化开发.html">
            
                <a href="../android基础/Apk插件化开发.html">
            
                    
                    Apk插件化开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.27" data-path="../android基础/App组件化开发.html">
            
                <a href="../android基础/App组件化开发.html">
            
                    
                    App组件化开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.28" data-path="../android基础/sdk开发.html">
            
                <a href="../android基础/sdk开发.html">
            
                    
                    sdk开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.29" data-path="../android基础/APP优化.html">
            
                <a href="../android基础/APP优化.html">
            
                    
                    APP优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.30" data-path="../android基础/项目参数配置.html">
            
                <a href="../android基础/项目参数配置.html">
            
                    
                    项目参数配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.31" data-path="../android基础/App发布.html">
            
                <a href="../android基础/App发布.html">
            
                    
                    App发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.32" data-path="../android基础/Android外挂.html">
            
                <a href="../android基础/Android外挂.html">
            
                    
                    Android外挂
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.33" data-path="../android基础/Android字节码插桩.html">
            
                <a href="../android基础/Android字节码插桩.html">
            
                    
                    Android字节码插桩
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.34" data-path="../android基础/智能家居.html">
            
                <a href="../android基础/智能家居.html">
            
                    
                    智能家居
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../python/python基础.html">
            
                <a href="../python/python基础.html">
            
                    
                    python部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../python/python基础.html">
            
                <a href="../python/python基础.html">
            
                    
                    python基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../python/python爬虫.html">
            
                <a href="../python/python爬虫.html">
            
                    
                    python爬虫
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../gradle/Groovy.html">
            
                <a href="../gradle/Groovy.html">
            
                    
                    Groovy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../kotlin/kotlin部分.html">
            
                <a href="../kotlin/kotlin部分.html">
            
                    
                    kotlin部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="../flutter/flutter部分.html">
            
                <a href="../flutter/flutter部分.html">
            
                    
                    flutter部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="../native/ccpp.html">
            
                <a href="../native/ccpp.html">
            
                    
                    native部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.17.1" data-path="../native/Linux.html">
            
                <a href="../native/Linux.html">
            
                    
                    Linux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.2" data-path="../native/ccpp.html">
            
                <a href="../native/ccpp.html">
            
                    
                    cCpp
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.3" data-path="../native/NDK.html">
            
                <a href="../native/NDK.html">
            
                    
                    NDK
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.4" data-path="../native/系统编译剪裁.html">
            
                <a href="../native/系统编译剪裁.html">
            
                    
                    系统编译剪裁
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.5" data-path="../native/音视频.html">
            
                <a href="../native/音视频.html">
            
                    
                    音视频
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.6" data-path="../native/音视频第三方库.html">
            
                <a href="../native/音视频第三方库.html">
            
                    
                    音视频第三方库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.7" data-path="../native/相关代码.html">
            
                <a href="../native/相关代码.html">
            
                    
                    相关代码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="../server/服务器部分.html">
            
                <a href="../server/服务器部分.html">
            
                    
                    服务器部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="../webDev/web部分.html">
            
                <a href="../webDev/web部分.html">
            
                    
                    web部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="../人工智能/人工智能相关概念.html">
            
                <a href="../人工智能/人工智能相关概念.html">
            
                    
                    人工智能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="../面试真题/极飞.html">
            
                <a href="../面试真题/极飞.html">
            
                    
                    面试真题
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >Android常用代码</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#&#x5E38;&#x7528;&#x4EE3;&#x7801;&#x7247;&#x6BB5;"><b>1. </b>&#x5E38;&#x7528;&#x4EE3;&#x7801;&#x7247;&#x6BB5;</a></li><ul><li><span class="title-icon "></span><a href="#&#x6570;&#x7EC4;&#x64CD;&#x4F5C;"><b>1.1. </b>&#x6570;&#x7EC4;&#x64CD;&#x4F5C;</a></li><ul><li><span class="title-icon "></span><a href="#list&#x53BB;&#x91CD;"><b>1.1.1. </b>list&#x53BB;&#x91CD;</a></li></ul><li><span class="title-icon "></span><a href="#string-&#x64CD;&#x4F5C;"><b>1.2. </b>String &#x64CD;&#x4F5C;</a></li><ul><li><span class="title-icon "></span><a href="#&#x5B57;&#x7B26;&#x4E32;&#x5207;&#x5272;"><b>1.2.1. </b>&#x5B57;&#x7B26;&#x4E32;&#x5207;&#x5272;</a></li><li><span class="title-icon "></span><a href="#string-&#x7B80;&#x5355;&#x683C;&#x5F0F;&#x5316;"><b>1.2.2. </b>String &#x7B80;&#x5355;&#x683C;&#x5F0F;&#x5316;</a></li><li><span class="title-icon "></span><a href="#spannablestring-&#x5173;&#x952E;&#x5B57;&#x5339;&#x914D;"><b>1.2.3. </b>SpannableString &#x5173;&#x952E;&#x5B57;&#x5339;&#x914D;</a></li><li><span class="title-icon "></span><a href="#strig-&#x548C;-byte-&#x4E92;&#x76F8;&#x8F6C;&#x6362;"><b>1.2.4. </b>strig &#x548C; byte[] &#x4E92;&#x76F8;&#x8F6C;&#x6362;</a></li></ul><li><span class="title-icon "></span><a href="#&#x4EE3;&#x7801;&#x8D85;&#x65F6;"><b>1.3. </b>&#x4EE3;&#x7801;&#x8D85;&#x65F6;</a></li><li><span class="title-icon "></span><a href="#&#x5BF9;&#x8C61;&#x6392;&#x5E8F;"><b>1.4. </b>&#x5BF9;&#x8C61;&#x6392;&#x5E8F;</a></li><li><span class="title-icon "></span><a href="#&#x6570;&#x7EC4;&#x64CD;&#x4F5C;_1"><b>1.5. </b>&#x6570;&#x7EC4;&#x64CD;&#x4F5C;</a></li><ul><li><span class="title-icon "></span><a href="#&#x6570;&#x7EC4;&#x76F8;&#x7B49;"><b>1.5.1. </b>&#x6570;&#x7EC4;&#x76F8;&#x7B49;</a></li><li><span class="title-icon "></span><a href="#&#x6570;&#x7EC4;&#x6253;&#x5370;"><b>1.5.2. </b>&#x6570;&#x7EC4;&#x6253;&#x5370;</a></li><li><span class="title-icon "></span><a href="#&#x6570;&#x7EC4;&#x6269;&#x5BB9;"><b>1.5.3. </b>&#x6570;&#x7EC4;&#x6269;&#x5BB9;</a></li></ul><li><span class="title-icon "></span><a href="#byte&#x76F8;&#x5173;"><b>1.6. </b>byte[]&#x76F8;&#x5173;</a></li><ul><li><span class="title-icon "></span><a href="#byte&#x548C;&#x57FA;&#x7840;&#x6570;&#x636E;&#x4E92;&#x8F6C;"><b>1.6.1. </b>byte[]&#x548C;&#x57FA;&#x7840;&#x6570;&#x636E;&#x4E92;&#x8F6C;</a></li><li><span class="title-icon "></span><a href="#&#x83B7;&#x5F97;&#x6821;&#x9A8C;&#x4F4D;"><b>1.6.2. </b>&#x83B7;&#x5F97;&#x6821;&#x9A8C;&#x4F4D;</a></li></ul><li><span class="title-icon "></span><a href="#&#x6587;&#x4EF6;&#x64CD;&#x4F5C;"><b>1.7. </b>&#x6587;&#x4EF6;&#x64CD;&#x4F5C;</a></li><ul><li><span class="title-icon "></span><a href="#&#x83B7;&#x5F97;&#x6307;&#x5B9A;&#x6587;&#x4EF6;&#x7684;byte&#x6570;&#x7EC4;"><b>1.7.1. </b>&#x83B7;&#x5F97;&#x6307;&#x5B9A;&#x6587;&#x4EF6;&#x7684;byte&#x6570;&#x7EC4;</a></li><li><span class="title-icon "></span><a href="#&#x6839;&#x636E;byte&#x6570;&#x7EC4;&#xFF0C;&#x751F;&#x6210;&#x6587;&#x4EF6;"><b>1.7.2. </b>&#x6839;&#x636E;byte&#x6570;&#x7EC4;&#xFF0C;&#x751F;&#x6210;&#x6587;&#x4EF6;</a></li><li><span class="title-icon "></span><a href="#&#x4FDD;&#x5B58;string&#x5230;&#x672C;&#x5730;"><b>1.7.3. </b>&#x4FDD;&#x5B58;String&#x5230;&#x672C;&#x5730;</a></li><li><span class="title-icon "></span><a href="#&#x4ECE;txt&#x5C0F;&#x6587;&#x4EF6;-&#x83B7;&#x53D6;string"><b>1.7.4. </b>&#x4ECE;txt(&#x5C0F;&#x6587;&#x4EF6;) &#x83B7;&#x53D6;String</a></li><li><span class="title-icon "></span><a href="#&#x6309;&#x884C;&#x8BFB;&#x53D6;&#x8F83;&#x5927;&#x6587;&#x4EF6;-&#x3001;&#x89E3;&#x51B3;&#x4E71;&#x7801;&#x95EE;&#x9898;"><b>1.7.5. </b>&#x6309;&#x884C;&#x8BFB;&#x53D6;(&#x8F83;&#x5927;&#x6587;&#x4EF6;) &#x3001;&#x89E3;&#x51B3;&#x4E71;&#x7801;&#x95EE;&#x9898;</a></li><li><span class="title-icon "></span><a href="#&#x9012;&#x5F52;-&#x904D;&#x5386;&#x6587;&#x4EF6;&#x5939;"><b>1.7.6. </b>&#x9012;&#x5F52; &#x904D;&#x5386;&#x6587;&#x4EF6;&#x5939;</a></li></ul><li><span class="title-icon "></span><a href="#&#x65F6;&#x95F4;&#x3001;&#x65E5;&#x671F;&#x76F8;&#x5173;"><b>1.8. </b>&#x65F6;&#x95F4;&#x3001;&#x65E5;&#x671F;&#x76F8;&#x5173;</a></li><ul><li><span class="title-icon "></span><a href="#&#x65F6;&#x95F4;&#x95F4;&#x9694;"><b>1.8.1. </b>&#x65F6;&#x95F4;&#x95F4;&#x9694;</a></li><li><span class="title-icon "></span><a href="#&#x79D2;&#x8F6C;&#x4E3A;-&#x5C0F;&#x65F6;&#x5206;&#x949F;&#x79D2;"><b>1.8.2. </b>&#x79D2;&#x8F6C;&#x4E3A; &#x5C0F;&#x65F6;+&#x5206;&#x949F;+&#x79D2;</a></li><li><span class="title-icon "></span><a href="#&#x65E5;&#x671F;&#x683C;&#x5F0F;&#x5316;"><b>1.8.3. </b>&#x65E5;&#x671F;&#x683C;&#x5F0F;&#x5316;</a></li><li><span class="title-icon "></span><a href="#&#x83B7;&#x53D6;&#x4ECA;&#x5929;&#x6700;&#x540E;&#x4E00;&#x79D2;&#x7684;&#x65F6;&#x95F4;"><b>1.8.4. </b>&#x83B7;&#x53D6;&#x4ECA;&#x5929;&#x6700;&#x540E;&#x4E00;&#x79D2;&#x7684;&#x65F6;&#x95F4;</a></li></ul><li><span class="title-icon "></span><a href="#&#x6C42;&#x5939;&#x89D2;"><b>1.9. </b>&#x6C42;&#x5939;&#x89D2;</a></li><ul><li><span class="title-icon "></span><a href="#&#x6839;&#x636E;&#x6B63;&#x5207;&#x516C;&#x5F0F;"><b>1.9.1. </b>&#x6839;&#x636E;&#x6B63;&#x5207;&#x516C;&#x5F0F;</a></li></ul><li><span class="title-icon "></span><a href="#&#x904D;&#x5386;map-&#x904D;&#x5386;set"><b>1.10. </b>&#x904D;&#x5386;map &#x904D;&#x5386;set</a></li><li><span class="title-icon "></span><a href="#list-&#x5206;&#x9875;"><b>1.11. </b>List &#x5206;&#x9875;</a></li><li><span class="title-icon "></span><a href="#&#x968F;&#x673A;&#x6570;-random"><b>1.12. </b>&#x968F;&#x673A;&#x6570; Random</a></li><ul><li><span class="title-icon "></span><a href="#&#x751F;&#x6210;-startnumendnum"><b>1.12.1. </b>&#x751F;&#x6210; [startNum,endNum)</a></li><li><span class="title-icon "></span><a href="#&#x751F;&#x6210;-startnumendnum_1"><b>1.12.2. </b>&#x751F;&#x6210; [startNum,endNum]</a></li></ul><li><span class="title-icon "></span><a href="#&#x6587;&#x4EF6;&#x89E3;&#x538B;&#x7F29;"><b>1.13. </b>&#x6587;&#x4EF6;&#x89E3;&#x538B;&#x7F29;</a></li><li><span class="title-icon "></span><a href="#resraw-&#x548C;-assets-&#x8BFB;&#x53D6;"><b>1.14. </b>res/raw &#x548C; assets &#x8BFB;&#x53D6;</a></li><li><span class="title-icon "></span><a href="#urlencoder-&#x4E2D;&#x6587;"><b>1.15. </b>URLEncoder &#x4E2D;&#x6587;</a></li><ul><li><span class="title-icon "></span><a href="#&#x5224;&#x65AD;&#x662F;&#x5426;&#x6709;&#x4E2D;&#x6587;"><b>1.15.1. </b>&#x5224;&#x65AD;&#x662F;&#x5426;&#x6709;&#x4E2D;&#x6587;</a></li><li><span class="title-icon "></span><a href="#&#x6B63;&#x5219;&#x6362;url&#x5B57;&#x7B26;&#x4E32;&#x91CC;&#x9762;&#x7684;&#x6C49;&#x5B57;&#x90E8;&#x5206;"><b>1.15.2. </b>&#x6B63;&#x5219;&#x6362;URL&#x5B57;&#x7B26;&#x4E32;&#x91CC;&#x9762;&#x7684;&#x6C49;&#x5B57;&#x90E8;&#x5206;</a></li></ul><li><span class="title-icon "></span><a href="#&#x5176;&#x4ED6;"><b>1.16. </b>&#x5176;&#x4ED6;</a></li><ul><li><span class="title-icon "></span><a href="#&#x5224;&#x65AD;&#x662F;&#x5426;&#x662F;&#x95F0;&#x5E74;"><b>1.16.1. </b>&#x5224;&#x65AD;&#x662F;&#x5426;&#x662F;&#x95F0;&#x5E74;</a></li><li><span class="title-icon "></span><a href="#&#x53CC;&#x51FB;&#x9000;&#x51FA;-&#x3001;&#x6309;&#x952E;&#x76D1;&#x542C;"><b>1.16.2. </b>&#x53CC;&#x51FB;&#x9000;&#x51FA; &#x3001;&#x6309;&#x952E;&#x76D1;&#x542C;</a></li><li><span class="title-icon "></span><a href="#&#x4E0D;&#x5B9A;&#x53C2;&#x6570;"><b>1.16.3. </b>&#x4E0D;&#x5B9A;&#x53C2;&#x6570;</a></li><li><span class="title-icon "></span><a href="#&#x5012;&#x8BA1;&#x65F6;"><b>1.16.4. </b>&#x5012;&#x8BA1;&#x65F6;</a></li><li><span class="title-icon "></span><a href="#&#x9009;&#x4E2D;&#x6548;&#x679C;"><b>1.16.5. </b>&#x9009;&#x4E2D;&#x6548;&#x679C;</a></li><li><span class="title-icon "></span><a href="#&#x70B9;&#x51FB;&#x6548;&#x679C;"><b>1.16.6. </b>&#x70B9;&#x51FB;&#x6548;&#x679C;</a></li><li><span class="title-icon "></span><a href="#&#x5168;&#x5C4F;&#x3001;&#x53BB;&#x6389;&#x6807;&#x9898;&#x680F;"><b>1.16.7. </b>&#x5168;&#x5C4F;&#x3001;&#x53BB;&#x6389;&#x6807;&#x9898;&#x680F;</a></li><li><span class="title-icon "></span><a href="#&#x542F;&#x52A8;&#x9ED8;&#x8BA4;&#x6D4F;&#x89C8;&#x5668;"><b>1.16.8. </b>&#x542F;&#x52A8;&#x9ED8;&#x8BA4;&#x6D4F;&#x89C8;&#x5668;</a></li><li><span class="title-icon "></span><a href="#&#x542F;&#x52A8;&#x7B2C;&#x4E09;&#x65B9;&#x5E94;&#x7528;"><b>1.16.9. </b>&#x542F;&#x52A8;&#x7B2C;&#x4E09;&#x65B9;&#x5E94;&#x7528;</a></li><li><span class="title-icon "></span><a href="#&#x7CFB;&#x7EDF;&#x5206;&#x4EAB;&#x529F;&#x80FD;"><b>1.16.10. </b>&#x7CFB;&#x7EDF;&#x5206;&#x4EAB;&#x529F;&#x80FD;</a></li><li><span class="title-icon "></span><a href="#&#x4F7F;&#x7528;&#x81EA;&#x5B9A;&#x4E49;&#x5B57;&#x4F53;"><b>1.16.11. </b>&#x4F7F;&#x7528;&#x81EA;&#x5B9A;&#x4E49;&#x5B57;&#x4F53;</a></li><li><span class="title-icon "></span><a href="#xml&#x89E3;&#x6790;"><b>1.16.12. </b>XML&#x89E3;&#x6790;</a></li><li><span class="title-icon "></span><a href="#&#x590D;&#x5236;&#x7C98;&#x8D34;"><b>1.16.13. </b>&#x590D;&#x5236;&#x7C98;&#x8D34;</a></li><li><span class="title-icon "></span><a href="#&#x9632;&#x6B62;-toast-&#x91CD;&#x590D;&#x63D0;&#x793A;"><b>1.16.14. </b>&#x9632;&#x6B62; Toast &#x91CD;&#x590D;&#x63D0;&#x793A;</a></li><li><span class="title-icon "></span><a href="#performclick"><b>1.16.15. </b>performClick</a></li><li><span class="title-icon "></span><a href="#&#x4FDD;&#x5B58;&#x63A7;&#x4EF6;&#x622A;&#x56FE;"><b>1.16.16. </b>&#x4FDD;&#x5B58;&#x63A7;&#x4EF6;&#x622A;&#x56FE;</a></li><li><span class="title-icon "></span><a href="#&#x56FE;&#x7247;&#x8F6C;byte"><b>1.16.17. </b>&#x56FE;&#x7247;&#x8F6C;byte[]</a></li><li><span class="title-icon "></span><a href="#&#x56FE;&#x7247;&#x8F6C;base64"><b>1.16.18. </b>&#x56FE;&#x7247;&#x8F6C;Base64</a></li><li><span class="title-icon "></span><a href="#&#x83B7;&#x53D6;-bitmap-&#x7F29;&#x7565;&#x56FE;"><b>1.16.19. </b>&#x83B7;&#x53D6; Bitmap &#x7F29;&#x7565;&#x56FE;</a></li><li><span class="title-icon "></span><a href="#&#x5360;&#x4F4D;&#x7B26;"><b>1.16.20. </b>&#x5360;&#x4F4D;&#x7B26;</a></li><li><span class="title-icon "></span><a href="#&#x56FE;&#x7247;&#x5E73;&#x94FA;"><b>1.16.21. </b>&#x56FE;&#x7247;&#x5E73;&#x94FA;</a></li><li><span class="title-icon "></span><a href="#&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x914D;&#x7F6E;"><b>1.16.22. </b>&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x914D;&#x7F6E;</a></li><li><span class="title-icon "></span><a href="#bytebuffer&#x76F8;&#x5173;"><b>1.16.23. </b>ByteBuffer&#x76F8;&#x5173;</a></li></ul><li><span class="title-icon "></span><a href="#&#x5982;&#x4F55;&#x5224;&#x65AD;&#x4E00;&#x4E2A;-app-&#x5728;&#x524D;&#x53F0;&#x8FD8;&#x662F;&#x540E;&#x53F0;"><b>1.17. </b>&#x5982;&#x4F55;&#x5224;&#x65AD;&#x4E00;&#x4E2A; APP &#x5728;&#x524D;&#x53F0;&#x8FD8;&#x662F;&#x540E;&#x53F0;</a></li></ul><li><span class="title-icon "></span><a href="#&#x76AE;&#x80A4;&#x66F4;&#x6362;-&#x3001;&#x66F4;&#x6362;&#x4E3B;&#x9898;"><b>2. </b>&#x76AE;&#x80A4;&#x66F4;&#x6362; &#x3001;&#x66F4;&#x6362;&#x4E3B;&#x9898;</a></li><ul><li><span class="title-icon "></span><a href="#&#x66F4;&#x6362;&#x76AE;&#x80A4;&#x6838;&#x5FC3;&#x539F;&#x7406;"><b>2.1. </b>&#x66F4;&#x6362;&#x76AE;&#x80A4;&#x6838;&#x5FC3;&#x539F;&#x7406;</a></li><li><span class="title-icon "></span><a href="#&#x6697;&#x9ED1;&#x6A21;&#x5F0F;&#x7701;&#x7535;&#x539F;&#x7406;"><b>2.2. </b>&#x6697;&#x9ED1;&#x6A21;&#x5F0F;&#x7701;&#x7535;&#x539F;&#x7406;</a></li><li><span class="title-icon "></span><a href="#&#x6362;&#x80A4;demo"><b>2.3. </b>&#x6362;&#x80A4;demo</a></li></ul></ul></div><a href="#&#x5E38;&#x7528;&#x4EE3;&#x7801;&#x7247;&#x6BB5;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="&#x5E38;&#x7528;&#x4EE3;&#x7801;&#x7247;&#x6BB5;"><a name="&#x5E38;&#x7528;&#x4EE3;&#x7801;&#x7247;&#x6BB5;" class="anchor-navigation-ex-anchor" href="#&#x5E38;&#x7528;&#x4EE3;&#x7801;&#x7247;&#x6BB5;"><i class="fa fa-link" aria-hidden="true"></i></a>1. &#x5E38;&#x7528;&#x4EE3;&#x7801;&#x7247;&#x6BB5;</h1>
<h2 id="&#x6570;&#x7EC4;&#x64CD;&#x4F5C;"><a name="&#x6570;&#x7EC4;&#x64CD;&#x4F5C;" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x7EC4;&#x64CD;&#x4F5C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. &#x6570;&#x7EC4;&#x64CD;&#x4F5C;</h2>
<h3 id="list&#x53BB;&#x91CD;"><a name="list&#x53BB;&#x91CD;" class="anchor-navigation-ex-anchor" href="#list&#x53BB;&#x91CD;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.1. list&#x53BB;&#x91CD;</h3>
<p>&#x5C06;&#x91CD;&#x590D;&#x503C;&#x53BB;&#x6389;&#xFF0C;&#x540C;&#x65F6;&#x4E0D;&#x80FD;&#x7834;&#x574F;&#x73B0;&#x6709;&#x7684;&#x987A;&#x5E8F;&#x3002;</p>
<pre><code class="lang-text">private  List&lt;String&gt; removeDuplicate(List&lt;String&gt; list){
  Set&lt;String&gt; set = new HashSet&lt;String&gt;();
  List&lt;String&gt; newList = new ArrayList&lt;String&gt;();
  for (String str : list) {
    // &#x501F;&#x52A9;set&#x7684;&#x7279;&#x6027;
    if (set.add(str)) {
      newList.add(str);
    }
  }
  return newList;
}
</code></pre>
<h2 id="string-&#x64CD;&#x4F5C;"><a name="string-&#x64CD;&#x4F5C;" class="anchor-navigation-ex-anchor" href="#string-&#x64CD;&#x4F5C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2. String &#x64CD;&#x4F5C;</h2>
<h3 id="&#x5B57;&#x7B26;&#x4E32;&#x5207;&#x5272;"><a name="&#x5B57;&#x7B26;&#x4E32;&#x5207;&#x5272;" class="anchor-navigation-ex-anchor" href="#&#x5B57;&#x7B26;&#x4E32;&#x5207;&#x5272;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2.1. &#x5B57;&#x7B26;&#x4E32;&#x5207;&#x5272;</h3>
<pre><code class="lang-text">String [] array= myString.split(&quot;[.]&quot;);
</code></pre>
<table>
<thead>
<tr>
<th>&#x5206;&#x5272;&#x5B57;&#x7B26;</th>
<th>&#x8868;&#x8FBE;</th>
</tr>
</thead>
<tbody>
<tr>
<td>.</td>
<td>&quot;[.]&quot;</td>
</tr>
<tr>
<td>|</td>
<td>&quot;\\|&quot;</td>
</tr>
<tr>
<td>*</td>
<td>&quot;\\*&quot;</td>
</tr>
<tr>
<td>\</td>
<td>&quot;\\\\&quot;</td>
</tr>
<tr>
<td>[</td>
<td>&quot;\\[&quot;</td>
</tr>
<tr>
<td>]</td>
<td>&quot;\\]&quot;</td>
</tr>
</tbody>
</table>
<h3 id="string-&#x7B80;&#x5355;&#x683C;&#x5F0F;&#x5316;"><a name="string-&#x7B80;&#x5355;&#x683C;&#x5F0F;&#x5316;" class="anchor-navigation-ex-anchor" href="#string-&#x7B80;&#x5355;&#x683C;&#x5F0F;&#x5316;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2.2. String &#x7B80;&#x5355;&#x683C;&#x5F0F;&#x5316;</h3>
<pre><code class="lang-text">return String.format(&quot;bookId= %s, bookName=%s]&quot;, bookId, bookName);
return String.format(&quot;%.1f&quot;,  value); // float double &#x7C7B;&#x578B;
</code></pre>
<h3 id="spannablestring-&#x5173;&#x952E;&#x5B57;&#x5339;&#x914D;"><a name="spannablestring-&#x5173;&#x952E;&#x5B57;&#x5339;&#x914D;" class="anchor-navigation-ex-anchor" href="#spannablestring-&#x5173;&#x952E;&#x5B57;&#x5339;&#x914D;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2.3. SpannableString &#x5173;&#x952E;&#x5B57;&#x5339;&#x914D;</h3>
<pre><code class="lang-text">public SpannableString showKeyWord(String str, String keyWord) {
    str = str == null ? &quot;&quot; : str;
    keyWord = keyWord == null ? &quot;&quot; : keyWord;

    Pattern pattern = Pattern.compile(keyWord);
    SpannableString spannableString = new SpannableString(str);
    Matcher matcher = pattern.matcher(spannableString);
    while (matcher.find()) {
        int start = matcher.start();
        int end = matcher.end();
        spannableString.setSpan(new ForegroundColorSpan(Color.RED), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    return spannableString;
}
tvShowInfo.setText(showKeyWord(info, &quot;&#x6D4B;&#x8BD5;&quot;));
</code></pre>
<h3 id="strig-&#x548C;-byte-&#x4E92;&#x76F8;&#x8F6C;&#x6362;"><a name="strig-&#x548C;-byte-&#x4E92;&#x76F8;&#x8F6C;&#x6362;" class="anchor-navigation-ex-anchor" href="#strig-&#x548C;-byte-&#x4E92;&#x76F8;&#x8F6C;&#x6362;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2.4. strig &#x548C; byte[] &#x4E92;&#x76F8;&#x8F6C;&#x6362;</h3>
<pre><code class="lang-text">byte[] bytes = &quot;hello world&quot;.getBytes(StandardCharsets.UTF_8);
String hello = new String(bytes , StandardCharsets.UTF_8);
</code></pre>
<h2 id="&#x4EE3;&#x7801;&#x8D85;&#x65F6;"><a name="&#x4EE3;&#x7801;&#x8D85;&#x65F6;" class="anchor-navigation-ex-anchor" href="#&#x4EE3;&#x7801;&#x8D85;&#x65F6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3. &#x4EE3;&#x7801;&#x8D85;&#x65F6;</h2>
<p>&#x51FD;&#x6570;&#x8D85;&#x65F6;&#x3001; &#x6267;&#x884C;&#x8D85;&#x65F6;&#x3001;&#x7B49;&#x5F85;&#x8D85;&#x65F6;&#x3001;&#x8FDE;&#x63A5;&#x8D85;&#x65F6;</p>
<pre><code class="lang-text">final ExecutorService exec = Executors.newFixedThreadPool(1);
Callable&lt;String&gt; call = new Callable&lt;String&gt;() {
    public String call() throws Exception {
        // &#x8017;&#x65F6;&#x64CD;&#x4F5C;...
        Thread.sleep(1000 * 3);
        return &quot;&#x6267;&#x884C;&#x7ED3;&#x679C;(&#x6210;&#x529F;&#x6216;&#x5931;&#x8D25;)&quot;;
    }
};

try {
    Future&lt;String&gt; future = exec.submit(call);
    // &#x8D85;&#x65F6;&#x65F6;&#x95F4; &#x8BBE;&#x7F6E;
    String result = future.get(1000 * 5, TimeUnit.MILLISECONDS);  
    System.out.println(&quot;&#x6267;&#x884C;&#x672A;&#x8D85;&#x65F6;:&quot; + result);
} catch (TimeoutException ex) {
    System.out.println(&quot;&#x5904;&#x7406;&#x8D85;&#x65F6;&quot;);
    ex.printStackTrace();
} catch (Exception e) {
    System.out.println(&quot;&#x5904;&#x7406;&#x5931;&#x8D25;.&quot;);
    e.printStackTrace();
}
    exec.shutdown();
}
</code></pre>
<h2 id="&#x5BF9;&#x8C61;&#x6392;&#x5E8F;"><a name="&#x5BF9;&#x8C61;&#x6392;&#x5E8F;" class="anchor-navigation-ex-anchor" href="#&#x5BF9;&#x8C61;&#x6392;&#x5E8F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4. &#x5BF9;&#x8C61;&#x6392;&#x5E8F;</h2>
<pre><code class="lang-text">Collections.sort(mBeanList, new Comparator&lt;MyBean&gt;() {
        @Override
        public int compare(MyBean bean1, MyBean bean2) {
            // &#x6309;&#x7167;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x6392;&#x5E8F;
          return = bean1.xx - bean2.xx;
        }
    });
</code></pre>
<h2 id="&#x6570;&#x7EC4;&#x64CD;&#x4F5C;_1"><a name="&#x6570;&#x7EC4;&#x64CD;&#x4F5C;_1" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x7EC4;&#x64CD;&#x4F5C;_1"><i class="fa fa-link" aria-hidden="true"></i></a>1.5. &#x6570;&#x7EC4;&#x64CD;&#x4F5C;</h2>
<h3 id="&#x6570;&#x7EC4;&#x76F8;&#x7B49;"><a name="&#x6570;&#x7EC4;&#x76F8;&#x7B49;" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x7EC4;&#x76F8;&#x7B49;"><i class="fa fa-link" aria-hidden="true"></i></a>1.5.1. &#x6570;&#x7EC4;&#x76F8;&#x7B49;</h3>
<pre><code class="lang-text">Arrays.equals(myArray, NSS_MSG_TYPE_GET_MAIN_STREAM);
</code></pre>
<h3 id="&#x6570;&#x7EC4;&#x6253;&#x5370;"><a name="&#x6570;&#x7EC4;&#x6253;&#x5370;" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x7EC4;&#x6253;&#x5370;"><i class="fa fa-link" aria-hidden="true"></i></a>1.5.2. &#x6570;&#x7EC4;&#x6253;&#x5370;</h3>
<pre><code class="lang-text">System.out.println(Arrays.toString(myArray));
</code></pre>
<h3 id="&#x6570;&#x7EC4;&#x6269;&#x5BB9;"><a name="&#x6570;&#x7EC4;&#x6269;&#x5BB9;" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x7EC4;&#x6269;&#x5BB9;"><i class="fa fa-link" aria-hidden="true"></i></a>1.5.3. &#x6570;&#x7EC4;&#x6269;&#x5BB9;</h3>
<pre><code class="lang-text">public  String [] getNewArrayWithMoreSpaceString(
String [] oldArray ,String [] increceData){
   String [] lastArray=new String[oldArray.length+increceData.length];
   //&#x6570;&#x7EC4;&#x590D;&#x5236;
   System.arraycopy(oldArray, 0, lastArray, 0, oldArray.length);
   System.arraycopy(increceData, 0, lastArray, oldArray.length+1, increceData.length);
   return   lastArray ;
}

/**
 * &#x591A;&#x4E2A;&#x6570;&#x7EC4;&#x5408;&#x5E76;
 */
byte[] concatAll(byte[] first, byte[]... rest) {
    int totalLength = first.length;
    for (byte[] array : rest) {
        totalLength += array.length;
    }
    byte[] result = Arrays.copyOf(first, totalLength);
    int offset = first.length;
    for (byte[] array : rest) {
        System.arraycopy(array, 0, result, offset, array.length);
        offset += array.length;
    }
    return result;
}
</code></pre>
<h2 id="byte&#x76F8;&#x5173;"><a name="byte&#x76F8;&#x5173;" class="anchor-navigation-ex-anchor" href="#byte&#x76F8;&#x5173;"><i class="fa fa-link" aria-hidden="true"></i></a>1.6. byte[]&#x76F8;&#x5173;</h2>
<h3 id="byte&#x548C;&#x57FA;&#x7840;&#x6570;&#x636E;&#x4E92;&#x8F6C;"><a name="byte&#x548C;&#x57FA;&#x7840;&#x6570;&#x636E;&#x4E92;&#x8F6C;" class="anchor-navigation-ex-anchor" href="#byte&#x548C;&#x57FA;&#x7840;&#x6570;&#x636E;&#x4E92;&#x8F6C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.6.1. byte[]&#x548C;&#x57FA;&#x7840;&#x6570;&#x636E;&#x4E92;&#x8F6C;</h3>
<pre><code class="lang-xml">&#x4F8B;&#x5982;&#x4E00;&#x4E2A;32&#x4F4D;long&#x6570;&#x636E;&#xFF0C;0x12345678:

             0x12345678
&#x9AD8;&#x5B57;&#x8282;   -----------------&gt;   &#x4F4E;&#x5B57;&#x8282;

&#x5185;&#x5B58;&#x4F4E;&#x5730;&#x5740; -----------------&gt;  &#x5185;&#x5B58;&#x9AD8;&#x5730;&#x5740;
&#x5927;&#x7AEF;&#x6A21;&#x5F0F;    0x12    0x34    0x56    0x78      //&#x7B26;&#x5408;&#x4EBA;&#x7684;&#x76F4;&#x89C2;&#x8BA4;&#x8BC6;
&#x5C0F;&#x7AEF;&#x6A21;&#x5F0F;    0x78    0x56    0x34    0x12
</code></pre>
<pre><code class="lang-text">// int &#x8F6C;&#x4E3A; byte
byte intTo1ByteHex(int intVaue ){
    return Integer.valueOf(intVaue &amp; 0xff).byteValue();
}

// byte &#x8F6C; int
int bytes1ToInt(byte  src) {
    return src  &amp; 0xFF;
}

// int &#x8F6C; byte[4]  ,&#x5927;&#x7AEF;&#x6A21;&#x5F0F;
byte[] intTo4ByteBig(int n) {
    byte[] b = new byte[4];
    b[3] = (byte) (n &amp; 0xff);
    b[2] = (byte) (n &gt;&gt; 8 &amp; 0xff);
    b[1] = (byte) (n &gt;&gt; 16 &amp; 0xff);
    b[0] = (byte) (n &gt;&gt; 24 &amp; 0xff);
    return b;
}

// int &#x8F6C; byte[4],&#x5C0F;&#x7AEF;&#x6A21;&#x5F0F;
byte[] intTo4ByteLittle(int n) {
    byte[] b = new byte[4];
    b[0] = (byte) (n &amp; 0xff);
    b[1] = (byte) (n &gt;&gt; 8 &amp; 0xff);
    b[2] = (byte) (n &gt;&gt; 16 &amp; 0xff);
    b[3] = (byte) (n &gt;&gt; 24 &amp; 0xff);
    return b;
}


// byte[4] &#x8F6C;int &#xFF0C;&#x5C0F;&#x7AEF;&#x6A21;&#x5F0F;
int bytes4ToIntLittle(byte[] bytes ) {
    int int1=bytes[0]&amp;0xff;
    int int2=(bytes[1]&amp;0xff)&lt;&lt; 8 ;
    int int3=(bytes[2]&amp;0xff)&lt;&lt; 16;
    int int4=(bytes[3]&amp;0xff)&lt;&lt;24;
    return int1|int2|int3|int4;
}


// byte[4] &#x8F6C; int &#xFF0C;&#x5927;&#x7AEF;
int bytes4ToIntBig(byte[] bytes ) {
    int int1=bytes[3]&amp;0xff;
    int int2=(bytes[2]&amp;0xff)&lt;&lt;8;
    int int3=(bytes[1]&amp;0xff)&lt;&lt;16;
    int int4=(bytes[0]&amp;0xff)&lt;&lt;24;
    return int1|int2|int3|int4;
}


// short &#x8F6C; byte[2] &#xFF0C;&#x5927;&#x7AEF;&#x6A21;&#x5F0F;
byte[] shortTo2ByteBig(short n) {
    byte[] b = new byte[2];
    b[1] = (byte) (n &amp; 0xff);
    b[0] = (byte) (n &gt;&gt; 8 &amp; 0xff);
    return b;
}


// short &#x8F6C; byte[2] &#xFF0C;&#x5C0F;&#x7AEF;&#x6A21;&#x5F0F;
byte[] shortTo2ByteLittle(short n) {
    byte[] b = new byte[2];
    b[0] = (byte) (n &amp; 0xff);
    b[1] = (byte) (n &gt;&gt; 8 &amp; 0xff);
    return b;
}

// byte[2] &#x8F6C; short ,&#x5C0F;&#x7AEF;&#x6A21;&#x5F0F;
short byte2ToShortLittle(byte[] b) {
    return (short) (((b[1] &lt;&lt; 8) | b[0] &amp; 0xff));
}

// byte[2] &#x8F6C; short ,&#x5927;&#x7AEF;&#x6A21;&#x5F0F;
short byteToShortBig(byte[] b) {
    return (short) (((b[0] &lt;&lt; 8) | b[1] &amp; 0xff));
}

// byte[2] &#x8F6C;short &#xFF0C;&#x5927;&#x7AEF;
short bytes2ToShort_Big(byte[] bytes) {
    return ByteBuffer.wrap(bytes).order(ByteOrder.BIG_ENDIAN).getShort();
}

// byte[2] &#x8F6C; short &#xFF0C;&#x5C0F;&#x7AEF;
short bytes2ToShort_Little(byte[] bytes) {
    return ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getShort();
}


/**
 * byte[4] &#x8F6C; float
 * @param littleEndian  &#x5C0F;&#x7AEF;&#x6A21;&#x5F0F;: rue , &#x5927;&#x7AEF;&#x6A21;&#x5F0F;: false
 */
private float bytes4ToFloat(byte[] bytes, boolean littleEndian) {
    ByteBuffer buffer = ByteBuffer.wrap(bytes,0,4);
    if(littleEndian){
        buffer.order(ByteOrder.LITTLE_ENDIAN);
    }else{
        buffer.order(ByteOrder.BIG_ENDIAN);
    }
    return   buffer.getFloat();
}


/**
 *  float &#x8F6C; byte[4 ]
 * @param littleEndian &#x5C0F;&#x7AEF;&#x6A21;&#x5F0F;: rue , &#x5927;&#x7AEF;&#x6A21;&#x5F0F;: false
 */
private byte[] float2Bytes4(  float valueF, boolean littleEndian) {
    ByteBuffer bbuf = ByteBuffer.allocate(4);
    bbuf.putFloat(valueF);
    byte[] bytes = bbuf.array();  //&#x9ED8;&#x8BA4;&#x5927;&#x7AEF;

    if(littleEndian){
        int size= bytes.length ;
        byte[ ] rollover = new byte[size] ;

        for(int i= 0 ; i&lt;size ;i++){
            rollover[i] = bytes[size-1 - i] ;
        }
        bytes = rollover ;
    }
    return  bytes ;
}


// double &#x8F6C; byte[8] ,&#x5C0F;&#x7AEF;&#x6A21;&#x5F0F;
byte[] doubleTo8Bytes_Little(double d){
    long value = Double.doubleToLongBits(d);
    byte[] b = new byte[8];
    b[7] = (byte)  (0xff &amp; (value &gt;&gt; 56));
    b[6] = (byte)  (0xff &amp; (value &gt;&gt; 48));
    b[5] = (byte)  (0xff &amp; (value &gt;&gt; 40));
    b[4] = (byte)  (0xff &amp; (value &gt;&gt; 32));
    b[3] = (byte)  (0xff &amp; (value &gt;&gt; 24));
    b[2] = (byte)  (0xff &amp; (value &gt;&gt; 16));
    b[1] = (byte)  (0xff &amp; (value &gt;&gt; 8));
    b[0] = (byte)  (0xff &amp; value);
    return b;
}


// double &#x8F6C; byte[8] ,&#x5927;&#x7AEF;&#x6A21;&#x5F0F;
byte[] doubleTo8Bytes_Big(double d){
    long l = Double.doubleToLongBits(d);
    byte[] b = new byte[8];
    b[0] = (byte)  (0xff &amp; (l &gt;&gt; 56));
    b[1] = (byte)  (0xff &amp; (l &gt;&gt; 48));
    b[2] = (byte)  (0xff &amp; (l &gt;&gt; 40));
    b[3] = (byte)  (0xff &amp; (l &gt;&gt; 32));
    b[4] = (byte)  (0xff &amp; (l &gt;&gt; 24));
    b[5] = (byte)  (0xff &amp; (l &gt;&gt; 16));
    b[6] = (byte)  (0xff &amp; (l &gt;&gt; 8));
    b[7] = (byte)  (0xff &amp; l);
    return b;
}

/**
 * byte[8] &#x8F6C; double
 */
double bytes8ToDouble(byte[] bytes, boolean littleEndian) {
    ByteBuffer buffer = ByteBuffer.wrap(bytes,0,8);
    if(littleEndian){
        buffer.order(ByteOrder.LITTLE_ENDIAN);
    }else{
        buffer.order(ByteOrder.BIG_ENDIAN);
    }
    long l = buffer.getLong();
    return Double.longBitsToDouble(l);
}
</code></pre>
<h3 id="&#x83B7;&#x5F97;&#x6821;&#x9A8C;&#x4F4D;"><a name="&#x83B7;&#x5F97;&#x6821;&#x9A8C;&#x4F4D;" class="anchor-navigation-ex-anchor" href="#&#x83B7;&#x5F97;&#x6821;&#x9A8C;&#x4F4D;"><i class="fa fa-link" aria-hidden="true"></i></a>1.6.2. &#x83B7;&#x5F97;&#x6821;&#x9A8C;&#x4F4D;</h3>
<pre><code class="lang-text">/*
&#x53EA;&#x4FDD;&#x7559;&#x4F4E;&#x516B;&#x4F4D;&#xFF0C;&#x9AD8;&#x4F4D;&#x820D;&#x53BB;&#x3002;
P1=s/256; //&#x6574;&#x9664;&#x9AD8;8&#x4F4D;
P0=s%256; //&#x53D6;&#x4F59;&#x662F;&#x4F4E;8&#x4F4D;
*/
public static  byte[] getVerifyValue(byte [] lastBytes){
    byte checksum =  0;
    for (int i = 0; i &lt;= lastBytes.length-2; i++) {
        checksum += lastBytes[i];
    }
    checksum = (byte) (checksum % 256) ;
    lastBytes[lastBytes.length-1] = checksum;
    return  lastBytes ;
}

// BCC &#x6821;&#x9A8C;&#x4F4D;&#x7B97;&#x6CD5;
byte BCC_CHECK(byte[] data, int bcccheck_lenth) {
    byte bcc_result = 0;
    for (int i = 0; i &lt; bcccheck_lenth; i++) {
        bcc_result ^=data[i];
    }
    return bcc_result;
}

// &#x4E00;&#x4E2A;byte&#x8F6C;&#x6362;byte[8]&#xFF0C;&#x6570;&#x7EC4;&#x6BCF;&#x4E2A;&#x503C;&#x4EE3;&#x8868;bit
public byte[] test(byte b) {
    byte[] array = new byte[8];
    for (int i = 7; i &gt;= 0; i--) {
        array[i] = (byte)(b &amp; 1);
        b = (byte) (b &gt;&gt; 1);
    }
    return array;
}

// byte[] &#x8F6C;&#x6362;&#x6210;&#x5341;&#x516D;&#x8FDB;&#x5236;&#x5B57;&#x7B26;&#x4E32; ,&#x65B9;&#x4FBF;&#x6253;&#x5370;&#x67E5;&#x770B;
String byte2HexStr(byte[] b){
    String stmp ;
    StringBuilder sb = new StringBuilder(&quot;&quot;);
    for (int n = 0; n &lt; b.length; n++) {
        stmp = Integer.toHexString(b[n] &amp; 0xFF);
        sb.append((stmp.length() == 1) ? &quot;0&quot; + stmp : stmp);
        sb.append(&quot; &quot;);
    }
    return sb.toString().toUpperCase().trim();
}
</code></pre>
<h2 id="&#x6587;&#x4EF6;&#x64CD;&#x4F5C;"><a name="&#x6587;&#x4EF6;&#x64CD;&#x4F5C;" class="anchor-navigation-ex-anchor" href="#&#x6587;&#x4EF6;&#x64CD;&#x4F5C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7. &#x6587;&#x4EF6;&#x64CD;&#x4F5C;</h2>
<h3 id="&#x83B7;&#x5F97;&#x6307;&#x5B9A;&#x6587;&#x4EF6;&#x7684;byte&#x6570;&#x7EC4;"><a name="&#x83B7;&#x5F97;&#x6307;&#x5B9A;&#x6587;&#x4EF6;&#x7684;byte&#x6570;&#x7EC4;" class="anchor-navigation-ex-anchor" href="#&#x83B7;&#x5F97;&#x6307;&#x5B9A;&#x6587;&#x4EF6;&#x7684;byte&#x6570;&#x7EC4;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7.1. &#x83B7;&#x5F97;&#x6307;&#x5B9A;&#x6587;&#x4EF6;&#x7684;byte&#x6570;&#x7EC4;</h3>
<pre><code class="lang-text">public  byte[] getBytesFromFile(File file){  
      byte[] buffer = null;  
      try {  
        if(!file.exists()){
          file.createNewFile();
        }
          FileInputStream fis = new FileInputStream(file);  
          ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);  
          byte[] b = new byte[1000];  
          int n;  
          while ((n = fis.read(b)) != -1) {  
              bos.write(b, 0, n);  
          }  
          fis.close();  
          bos.close();  
          buffer = bos.toByteArray();  
      } catch ( Exception e) {  
          e.printStackTrace();  
      }  
      return buffer;  
  }
</code></pre>
<h3 id="&#x6839;&#x636E;byte&#x6570;&#x7EC4;&#xFF0C;&#x751F;&#x6210;&#x6587;&#x4EF6;"><a name="&#x6839;&#x636E;byte&#x6570;&#x7EC4;&#xFF0C;&#x751F;&#x6210;&#x6587;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#&#x6839;&#x636E;byte&#x6570;&#x7EC4;&#xFF0C;&#x751F;&#x6210;&#x6587;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7.2. &#x6839;&#x636E;byte&#x6570;&#x7EC4;&#xFF0C;&#x751F;&#x6210;&#x6587;&#x4EF6;</h3>
<pre><code class="lang-text">public void getFileFromBytes(byte[] bfile, File file ,boolean isAppend){  
    BufferedOutputStream bos = null;  
    FileOutputStream fos = null;  
    try {  
        fos = new FileOutputStream(file ,isAppend);  
        bos = new BufferedOutputStream(fos );  
        bos.write(bfile);  
    } catch (Exception e) {  
        e.printStackTrace();  
    } finally {  
        if (bos != null) {  
            try {  
                bos.close();  
            } catch (IOException e1) {  
                e1.printStackTrace();  
            }  
        }  
        if (fos != null) {  
            try {  
                fos.close();  
            } catch (IOException e1) {  
                e1.printStackTrace();  
            }  
        }  
    }  
}
</code></pre>
<h3 id="&#x4FDD;&#x5B58;string&#x5230;&#x672C;&#x5730;"><a name="&#x4FDD;&#x5B58;string&#x5230;&#x672C;&#x5730;" class="anchor-navigation-ex-anchor" href="#&#x4FDD;&#x5B58;string&#x5230;&#x672C;&#x5730;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7.3. &#x4FDD;&#x5B58;String&#x5230;&#x672C;&#x5730;</h3>
<pre><code class="lang-text">public  boolean saveTxtToSdWithAppend(String messgeStr,  String filePath, boolean isAppend){
     File file = new File(filePath);
     try {
         file.createNewFile();
     } catch (IOException e) {
         e.printStackTrace();
     }

     boolean resultFlage = true;
     try {
         // &#x6253;&#x5F00;&#x4E00;&#x4E2A;&#x5199;&#x6587;&#x4EF6;&#x5668;&#xFF0C;&#x662F;&#x5426;&#x8FFD;&#x52A0;&#x5F62;&#x5F0F;
         FileWriter writer = new FileWriter(filePath, isAppend);
         writer.write(messgeStr + &quot;\r\n&quot;);
         writer.close();
     } catch (IOException e) {
         resultFlage = false;
         e.printStackTrace();
     }
     return resultFlage;
 }
</code></pre>
<h3 id="&#x4ECE;txt&#x5C0F;&#x6587;&#x4EF6;-&#x83B7;&#x53D6;string"><a name="&#x4ECE;txt&#x5C0F;&#x6587;&#x4EF6;-&#x83B7;&#x53D6;string" class="anchor-navigation-ex-anchor" href="#&#x4ECE;txt&#x5C0F;&#x6587;&#x4EF6;-&#x83B7;&#x53D6;string"><i class="fa fa-link" aria-hidden="true"></i></a>1.7.4. &#x4ECE;txt(&#x5C0F;&#x6587;&#x4EF6;) &#x83B7;&#x53D6;String</h3>
<pre><code class="lang-text">public  String getStringFromTxt(File file) {
    StringBuffer sb = new StringBuffer();
    try {
        BufferedReader rd = new BufferedReader(new FileReader(file));
        String s = rd.readLine();
        while (null != s) {
            sb.append(s);
            s = rd.readLine();
        }

    } catch (FileNotFoundException e) {
        e.printStackTrace();   
    } catch (IOException e) {
        e.printStackTrace();
    }
    return sb.toString();
}
</code></pre>
<h3 id="&#x6309;&#x884C;&#x8BFB;&#x53D6;&#x8F83;&#x5927;&#x6587;&#x4EF6;-&#x3001;&#x89E3;&#x51B3;&#x4E71;&#x7801;&#x95EE;&#x9898;"><a name="&#x6309;&#x884C;&#x8BFB;&#x53D6;&#x8F83;&#x5927;&#x6587;&#x4EF6;-&#x3001;&#x89E3;&#x51B3;&#x4E71;&#x7801;&#x95EE;&#x9898;" class="anchor-navigation-ex-anchor" href="#&#x6309;&#x884C;&#x8BFB;&#x53D6;&#x8F83;&#x5927;&#x6587;&#x4EF6;-&#x3001;&#x89E3;&#x51B3;&#x4E71;&#x7801;&#x95EE;&#x9898;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7.5. &#x6309;&#x884C;&#x8BFB;&#x53D6;(&#x8F83;&#x5927;&#x6587;&#x4EF6;) &#x3001;&#x89E3;&#x51B3;&#x4E71;&#x7801;&#x95EE;&#x9898;</h3>
<pre><code class="lang-text">public void read(String filePath, String logPath) throws  Exception {
  RandomAccessFile raf = new RandomAccessFile(filePath, &quot;r&quot;);
  // &#x8BBE;&#x7F6E;&#x6307;&#x9488;&#x7684;&#x4F4D;&#x7F6E;&#x4E3A;&#x6587;&#x4EF6;&#x7684;&#x5F00;&#x59CB;&#x90E8;&#x5206;
  raf.seek(currentInex);
  long totalLenth = raf.length();
  while (currentInex &lt;= totalLenth) {
    String stringValue = new String(raf.readLine().getBytes(&quot;ISO-8859-1&quot;), &quot;utf-8&quot;);
    currentInex = raf.getFilePointer();
    raf.close();
  }
}
</code></pre>
<h3 id="&#x9012;&#x5F52;-&#x904D;&#x5386;&#x6587;&#x4EF6;&#x5939;"><a name="&#x9012;&#x5F52;-&#x904D;&#x5386;&#x6587;&#x4EF6;&#x5939;" class="anchor-navigation-ex-anchor" href="#&#x9012;&#x5F52;-&#x904D;&#x5386;&#x6587;&#x4EF6;&#x5939;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7.6. &#x9012;&#x5F52; &#x904D;&#x5386;&#x6587;&#x4EF6;&#x5939;</h3>
<pre><code class="lang-text">public void  getFileList(String strPath) {
      File dir = new File(strPath);
      File[] files = dir.listFiles();  
      if (files != null) {
          for (File file : files) {
              if (file.isDirectory()) {  
                  getFileList(file.getAbsolutePath());  
              } else {
                  // &#x6587;&#x4EF6;
              }
          }
      }
  }
</code></pre>
<h2 id="&#x65F6;&#x95F4;&#x3001;&#x65E5;&#x671F;&#x76F8;&#x5173;"><a name="&#x65F6;&#x95F4;&#x3001;&#x65E5;&#x671F;&#x76F8;&#x5173;" class="anchor-navigation-ex-anchor" href="#&#x65F6;&#x95F4;&#x3001;&#x65E5;&#x671F;&#x76F8;&#x5173;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8. &#x65F6;&#x95F4;&#x3001;&#x65E5;&#x671F;&#x76F8;&#x5173;</h2>
<h3 id="&#x65F6;&#x95F4;&#x95F4;&#x9694;"><a name="&#x65F6;&#x95F4;&#x95F4;&#x9694;" class="anchor-navigation-ex-anchor" href="#&#x65F6;&#x95F4;&#x95F4;&#x9694;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8.1. &#x65F6;&#x95F4;&#x95F4;&#x9694;</h3>
<pre><code class="lang-text">public static String getConversationDateString(String result) throws  Exception{
  if(!result.equals(&quot;&quot;)){
    SimpleDateFormat sdf = new SimpleDateFormat(&quot;MM-dd HH:mm&quot;);
    SimpleDateFormat sdfDay = new SimpleDateFormat(&quot;MM-dd&quot;);
    String now = sdf.format(new Date());
    Date oldTime = null;
    Date newTime = null;
    oldTime = sdf.parse(result);
    newTime = sdf.parse(now);

    long time = newTime.getTime() - oldTime.getTime();
    int day;
    String[] olds = sdfDay.format(oldTime).split(&quot;-&quot;);
    String[] news = sdfDay.format(newTime).split(&quot;-&quot;);

    if(news[0].equals(olds[0])){
      day = Integer.valueOf(news[1]) - Integer.valueOf(olds[1]);
    }else{
      Calendar cal = Calendar.getInstance();  
      //&#x6708;&#x4EFD;&#x8BBE;&#x7F6E;&#x8981;&#x51CF;1&#xFF0C;&#x6240;&#x4EE5;&#x8BBE;&#x7F6E;1&#x6708;&#x5C31;&#x662F;1-1&#xFF0C;&#x8BBE;&#x7F6E;2&#x6708;&#x5C31;&#x662F;2-1&#xFF0C;&#x5982;&#x6B64;&#x7C7B;&#x63A8;  
      cal.set(Calendar.MONTH, 1-1);  
      cal.add(Calendar.MONTH, -(Integer.valueOf(news[0]) - Integer.valueOf(olds[0])));  
      //&#x5F97;&#x5230;&#x4E0A;&#x4E00;&#x4E2A;&#x6708;&#x6700;&#x6700;&#x540E;&#x4E00;&#x5929;&#x65E5;&#x671F;(31/30/29/28)  
      int oldDay=cal.getActualMaximum(Calendar.DAY_OF_MONTH) - Integer.valueOf(olds[1]);  
      day = oldDay + Integer.valueOf(news[1]);
    }

    if(time &lt;= 24 * 60 * 60 * 1000){
      if(time &lt;= 60 * 1000){
        return &quot;&#x521A;&#x521A;&quot;;
      }else if (time &lt;= 60 * 60 * 1000) {
        result = (time/60/1000) + &quot;&#x5206;&#x949F;&#x524D;&quot;;
      } else {
        result = (time/60/60/1000) + &quot;&#x5C0F;&#x65F6;&#x524D;&quot;;
      }
    }else if(day == 1){
      result = &quot;&#x6628;&#x5929;&quot;;
    }else if(day == 2){
      result = &quot;&#x524D;&#x5929;&quot;;
    }else if(day &lt; 7){
      result = day + &quot;&#x5929;&#x524D;&quot;;
    }else {
      result = sdfDay.format(oldTime);
    }
  }
  return result;
}
</code></pre>
<h3 id="&#x79D2;&#x8F6C;&#x4E3A;-&#x5C0F;&#x65F6;&#x5206;&#x949F;&#x79D2;"><a name="&#x79D2;&#x8F6C;&#x4E3A;-&#x5C0F;&#x65F6;&#x5206;&#x949F;&#x79D2;" class="anchor-navigation-ex-anchor" href="#&#x79D2;&#x8F6C;&#x4E3A;-&#x5C0F;&#x65F6;&#x5206;&#x949F;&#x79D2;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8.2. &#x79D2;&#x8F6C;&#x4E3A; &#x5C0F;&#x65F6;+&#x5206;&#x949F;+&#x79D2;</h3>
<pre><code class="lang-text">/**
 * &#x79D2;&#x8F6C;&#x4E3A; &#x5C0F;&#x65F6;+&#x5206;&#x949F;+&#x79D2; &#x663E;&#x793A;
 * @param  second &#x79D2;
 */
public static String getHourAndMinute(int second , StringBuilder sb ) {
    if(sb==null){
        sb=new StringBuilder();
    }
    sb.delete(0,sb.length()) ;

    int hour = second / 3600;
    int minute = (second - hour * 3600) / 60;
    second = second - hour * 3600 - minute * 60;

    if(hour&gt;0){
        sb.append(hour).append(&quot;h&quot;) ;
    }

    if(minute&gt;0){
        sb.append(minute).append(&quot;min&quot;) ;
    }

    if(second&gt;=0){
        sb.append(second).append(&quot;s&quot;) ;
    }
    return sb.toString();
}
</code></pre>
<h3 id="&#x65E5;&#x671F;&#x683C;&#x5F0F;&#x5316;"><a name="&#x65E5;&#x671F;&#x683C;&#x5F0F;&#x5316;" class="anchor-navigation-ex-anchor" href="#&#x65E5;&#x671F;&#x683C;&#x5F0F;&#x5316;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8.3. &#x65E5;&#x671F;&#x683C;&#x5F0F;&#x5316;</h3>
<pre><code class="lang-text">/**
 * &quot;yyyy-MM-dd HH:mm:ss&quot;
 *  &#x5C06; &quot;1970-1-1 12:25:01&quot;  &#x5B57;&#x7B26;&#x4E32; &#x8F6C;&#x4E3A; long &#x7C7B;&#x578B;&#x7684; &#x65F6;&#x95F4;
 */
public long getMillisecondsTimeFromStrYyyyMMddHHmmss(String timeStr){
    DateFormat format = new SimpleDateFormat(&quot;yyyy-MM-dd HH:mm:ss&quot; ,Locale.getDefault());
    Date date  = null;
    try {
        date = format.parse(timeStr);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date==null ? 0: date.getTime() ;
}

public String getFormatDateStringYyyyMMddHHmmssFromLongTime(long mills) {
    Date date = new Date(mills);
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(&quot;yyyy-MM-dd HH:mm:ss&quot;,Locale.getDefault());
    return simpleDateFormat.format(date);
}
</code></pre>
<h3 id="&#x83B7;&#x53D6;&#x4ECA;&#x5929;&#x6700;&#x540E;&#x4E00;&#x79D2;&#x7684;&#x65F6;&#x95F4;"><a name="&#x83B7;&#x53D6;&#x4ECA;&#x5929;&#x6700;&#x540E;&#x4E00;&#x79D2;&#x7684;&#x65F6;&#x95F4;" class="anchor-navigation-ex-anchor" href="#&#x83B7;&#x53D6;&#x4ECA;&#x5929;&#x6700;&#x540E;&#x4E00;&#x79D2;&#x7684;&#x65F6;&#x95F4;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8.4. &#x83B7;&#x53D6;&#x4ECA;&#x5929;&#x6700;&#x540E;&#x4E00;&#x79D2;&#x7684;&#x65F6;&#x95F4;</h3>
<pre><code class="lang-text">public static long getlongTimeOfTodayYyyyMMddHHmmss(){
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    return  calendar.getTimeInMillis(); //&#x4ECA;&#x5929;
}
</code></pre>
<h2 id="&#x6C42;&#x5939;&#x89D2;"><a name="&#x6C42;&#x5939;&#x89D2;" class="anchor-navigation-ex-anchor" href="#&#x6C42;&#x5939;&#x89D2;"><i class="fa fa-link" aria-hidden="true"></i></a>1.9. &#x6C42;&#x5939;&#x89D2;</h2>
<h3 id="&#x6839;&#x636E;&#x6B63;&#x5207;&#x516C;&#x5F0F;"><a name="&#x6839;&#x636E;&#x6B63;&#x5207;&#x516C;&#x5F0F;" class="anchor-navigation-ex-anchor" href="#&#x6839;&#x636E;&#x6B63;&#x5207;&#x516C;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.9.1. &#x6839;&#x636E;&#x6B63;&#x5207;&#x516C;&#x5F0F;</h3>
<pre><code class="lang-text">/**&#x6839;&#x636E;&#x4E24;&#x4E2A;&#x70B9;&#x83B7;&#x53D6; &#x659C;&#x7387;*/
public static double getXl(MyPointBean bean1, MyPointBean bean2) {
    double xlValue = 0;
    xlValue = (bean2.getY() - bean1.getY()) / (bean2.getX() - bean1.getX());
    return xlValue;
}

/**&#x6839;&#x636E;2&#x6761;&#x7EBF;&#x7684;&#x659C;&#x7387; &#x83B7;&#x5F97;&#x4E4B;&#x95F4;&#x7684;&#x5939;&#x89D2;*/
public static double getAngle(double xl_1, double xl_2) {
    double angleValue = 0;
    // &#x53CD;&#x6B63;&#x5207;
    angleValue = Math.atan((xl_2 - xl_1) / (1 + xl_1 * xl_2));
    // &#x5C06;&#x5F27;&#x5EA6;&#x8F6C;&#x4E3A;&#x5EA6;&#x6570;
    return Math.toDegrees(angleValue);
}
</code></pre>
<h2 id="&#x904D;&#x5386;map-&#x904D;&#x5386;set"><a name="&#x904D;&#x5386;map-&#x904D;&#x5386;set" class="anchor-navigation-ex-anchor" href="#&#x904D;&#x5386;map-&#x904D;&#x5386;set"><i class="fa fa-link" aria-hidden="true"></i></a>1.10. &#x904D;&#x5386;map &#x904D;&#x5386;set</h2>
<pre><code class="lang-text">Map&lt;String ,Integer&gt;  map=new HashMap();
//&#x65B9;&#x6CD5;&#x4E00; &#xFF0C;&#x9700;&#x8981;&#x904D;&#x5386; &#x4E24;&#x6B21;     
for (Object object : map.keySet()) {
 String key = (String) object;
 Integer value = (Integer) map.get(key);
}

// &#x65B9;&#x6CD5;&#x4E8C;&#xFF0C; &#x53EA;&#x9700;&#x904D;&#x5386;&#x4E00;&#x6B21; &#xFF08;&#x63A8;&#x8350;&#xFF09;
Set&lt;Entry&lt;String, Integer&gt;&gt;  entrySet = map.entrySet();
for (Entry&lt;String, Integer&gt; object : entrySet){
 Object key = object.getKey();
 Object value = object.getValue();
}

//&#x904D;&#x5386;set
Set&lt;String&gt; set=new HashSet();
Iterator&lt;String&gt; iterator=set.iterator();
while (iterator.hasNext()) {
  String obj = iterator.next();
}
</code></pre>
<h2 id="list-&#x5206;&#x9875;"><a name="list-&#x5206;&#x9875;" class="anchor-navigation-ex-anchor" href="#list-&#x5206;&#x9875;"><i class="fa fa-link" aria-hidden="true"></i></a>1.11. List &#x5206;&#x9875;</h2>
<pre><code class="lang-text">https://gitee.com/Aivin_CodeShare/android_tool_code/raw/master/ListPageUtil.java

&#x8FD9;&#x91CC;&#x6709;&#x7528;&#x5230; List&#x7684; subList() &#x51FD;&#x6570;&#x3002;
&#x4E0D;&#x8FC7;&#x8981;&#x6CE8;&#x610F;&#x4E00;&#x4E2A;&#x95EE;&#x9898;&#xFF1A;
subList &#x8FD4;&#x56DE;&#x7684;&#x662F; ArrayList&#x7684;&#x5185;&#x90E8;&#x7C7B; SubList&#x3002;
&#x5BF9;&#x5B50;&#x5217;&#x8868;&#x6216;&#x539F;&#x5217;&#x8868;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x4F1A;&#x5F71;&#x54CD;&#x5230;&#x5F7C;&#x6B64;&#x3002;
&#x800C;&#x4E14;&#x5982;&#x679C;&#x5BF9;&#x539F;&#x5217;&#x8868;&#x589E;&#x5220;&#x64CD;&#x4F5C;&#x540E;&#xFF0C;&#x82E5;&#x5BF9;&#x5B50;&#x5217;&#x8868;&#x505A;&#x589E;&#x5220;&#x6539;&#x67E5;&#xFF0C;&#x90FD;&#x4F1A;&#x62A5;&#x9519;&#x5D29;&#x6E83;&#x3002;

&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x4E00;&#x822C;&#x4F1A;&#x91CD;&#x65B0;&#x65B0;&#x5EFA;&#x4E00;&#x4E2A; 
subList = new ArrayList&lt;&gt;(list.subList(pageIndex * pageSize, listSize));
</code></pre>
<h2 id="&#x968F;&#x673A;&#x6570;-random"><a name="&#x968F;&#x673A;&#x6570;-random" class="anchor-navigation-ex-anchor" href="#&#x968F;&#x673A;&#x6570;-random"><i class="fa fa-link" aria-hidden="true"></i></a>1.12. &#x968F;&#x673A;&#x6570; Random</h2>
<p>Math.Random() &#x8303;&#x56F4;&#x662F; [0,1)</p>
<h3 id="&#x751F;&#x6210;-startnumendnum"><a name="&#x751F;&#x6210;-startnumendnum" class="anchor-navigation-ex-anchor" href="#&#x751F;&#x6210;-startnumendnum"><i class="fa fa-link" aria-hidden="true"></i></a>1.12.1. &#x751F;&#x6210; [startNum,endNum)</h3>
<pre><code class="lang-text">public int getRadomInt(int startNum, int endNum){
  return new Random().nextInt(endNum - startNum) + startNum;
}
</code></pre>
<h3 id="&#x751F;&#x6210;-startnumendnum_1"><a name="&#x751F;&#x6210;-startnumendnum_1" class="anchor-navigation-ex-anchor" href="#&#x751F;&#x6210;-startnumendnum_1"><i class="fa fa-link" aria-hidden="true"></i></a>1.12.2. &#x751F;&#x6210; [startNum,endNum]</h3>
<pre><code class="lang-text">public int getRadomInt2(int startNum, int endNum){
  return new  Random().nextInt(endNum - startNum + 1) + startNum;
}
</code></pre>
<h2 id="&#x6587;&#x4EF6;&#x89E3;&#x538B;&#x7F29;"><a name="&#x6587;&#x4EF6;&#x89E3;&#x538B;&#x7F29;" class="anchor-navigation-ex-anchor" href="#&#x6587;&#x4EF6;&#x89E3;&#x538B;&#x7F29;"><i class="fa fa-link" aria-hidden="true"></i></a>1.13. &#x6587;&#x4EF6;&#x89E3;&#x538B;&#x7F29;</h2>
<p>zip&#x89E3;&#x538B;&#x7F29;&#x662F;&#x57FA;&#x4E8E; pache&#x7684; ant.jar &#x5B9E;&#x73B0; &#x3002;</p>
<pre><code class="lang-text">/**
 * &#x89E3;&#x538B;&#x8017;&#x65F6;&#x64CD;&#x4F5C;&#x5E94;&#x8BE5;&#x5728;&#x5B50;&#x7EBF;&#x7A0B;&#x4E2D;&#x8FDB;&#x884C;&#x3002;
 */
public class ZipUtil{
        private byte[] buf;
      public ZipUtil(){
          this.buf = new byte[ 1024*4];
      }

    /**
     * @param zipFileAbsulutPaht &#x538B;&#x7F29;&#x6587;&#x4EF6;&#x7684;&#x7EDD;&#x5BF9;&#x8DEF;&#x5F84;  xxx/xxx.zip
     * @param destFileDir&#x3000;&#x3000;&#x3000;&#x89E3;&#x538B;&#x5230;&#x7684;&#x76EE;&#x5F55;&#x3000;
     */
    public void unZip(String zipFileAbsulutPaht, String destFileDir)  {
        FileOutputStream fileOut;
        File file;
        InputStream inputStream;

        try {
            //&#x751F;&#x6210;&#x4E00;&#x4E2A;zip&#x7684;&#x6587;&#x4EF6;
            ZipFile  zipFile = new ZipFile(zipFileAbsulutPaht);
            //&#x904D;&#x5386;zipFile&#x4E2D;&#x6240;&#x6709;&#x7684;&#x5B9E;&#x4F53;&#xFF0C;&#x5E76;&#x628A;&#x4ED6;&#x4EEC;&#x89E3;&#x538B;&#x51FA;&#x6765;
            for (@SuppressWarnings(&quot;unchecked&quot;) Enumeration&lt;ZipEntry&gt; entries = zipFile.getEntries(); entries.hasMoreElements();)  {
                ZipEntry entry =  entries.nextElement();
                //&#x751F;&#x6210;&#x4ED6;&#x4EEC;&#x89E3;&#x538B;&#x540E;&#x7684;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;
                String tempNameFile=entry.getName() ;
                file = new File(destFileDir+File.separator+tempNameFile.replace(&quot;\\&quot;, &quot;/&quot;));

                if (entry.isDirectory())  {
                    file.mkdirs();
                } else {
                    File parent = file.getParentFile();
                    if (!parent.exists())  {
                        parent.mkdirs();
                    }
                    //&#x83B7;&#x53D6;&#x51FA;&#x8BE5;&#x538B;&#x7F29;&#x5B9E;&#x4F53;&#x7684;&#x8F93;&#x5165;&#x6D41;
                    inputStream = zipFile.getInputStream(entry);
                    fileOut = new FileOutputStream(file);
                    int length = 0;
                    //&#x5C06;&#x5B9E;&#x4F53;&#x5199;&#x5230;&#x672C;&#x5730;&#x6587;&#x4EF6;&#x4E2D;&#x53BB;
                    while ((length = inputStream.read(this.buf)) &gt; 0)  {
                        fileOut.write(this.buf, 0, length);
                    }
                    fileOut.close();
                    inputStream.close();
                }
            }
            zipFile.close();
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
}

// &#x4F7F;&#x7528;
new ZipUtil().unZip(mnt/xxx/xxx.zip , mnt/xx/xx/);
</code></pre>
<h2 id="resraw-&#x548C;-assets-&#x8BFB;&#x53D6;"><a name="resraw-&#x548C;-assets-&#x8BFB;&#x53D6;" class="anchor-navigation-ex-anchor" href="#resraw-&#x548C;-assets-&#x8BFB;&#x53D6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.14. res/raw &#x548C; assets &#x8BFB;&#x53D6;</h2>
<pre><code class="lang-text">// res/raw&#x548C;assets&#x7684;&#x76F8;&#x540C;&#x70B9;&#xFF1A;
1&#x3001;&#x4E24;&#x8005;&#x76EE;&#x5F55;&#x4E0B;&#x7684;&#x6587;&#x4EF6;&#x5728;&#x6253;&#x5305;&#x540E;&#x4F1A;&#x539F;&#x5C01;&#x4E0D;&#x52A8;&#x7684;&#x4FDD;&#x5B58;&#x5728;apk&#x5305;&#x4E2D;&#xFF0C;&#x4E0D;&#x4F1A;&#x88AB;&#x7F16;&#x8BD1;&#x6210;&#x4E8C;&#x8FDB;&#x5236;&#x3002;

//  res/raw&#x548C;assets&#x7684;&#x4E0D;&#x540C;&#x70B9;&#xFF1A;
1&#x3001;res/raw&#x4E2D;&#x7684;&#x6587;&#x4EF6;&#x4F1A;&#x88AB;&#x6620;&#x5C04;&#x5230;R.java&#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x8BBF;&#x95EE;&#x7684;&#x65F6;&#x5019;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x8D44;&#x6E90;ID&#x5373;R.id.filename&#xFF1B;
2&#x3001;assets&#x6587;&#x4EF6;&#x5939;&#x4E0B;&#x7684;&#x6587;&#x4EF6;&#x4E0D;&#x4F1A;&#x88AB;&#x6620;&#x5C04;&#x5230;R.java&#x4E2D;&#xFF0C;&#x8BBF;&#x95EE;&#x7684;&#x65F6;&#x5019;&#x9700;&#x8981;AssetManager&#x7C7B;&#x3002;
3&#x3001;res/raw&#x4E0D;&#x53EF;&#x4EE5;&#x6709;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#xFF1B;
4&#x3001;&#x800C;assets&#x5219;&#x53EF;&#x4EE5;&#x6709;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;assets&#x76EE;&#x5F55;&#x4E0B;&#x53EF;&#x4EE5;&#x518D;&#x5EFA;&#x7ACB;&#x6587;&#x4EF6;&#x5939;

/**
 * &#x83B7;&#x53D6; assets &#x76EE;&#x5F55;&#x4E0B;&#x7684; json&#x6587;&#x4EF6;&#x6570;&#x636E; &lt;br&gt;
 * String distsData = new HXGetJsonDataTool().getJsonFromAssets(activity, &quot;testjson.txt&quot;);
 */
public static String getJsonFromAssets(Context context, String fileName) {
    StringBuilder stringBuilder = new StringBuilder();
    try {
        AssetManager assetManager = context.getAssets();
        BufferedReader bf = new BufferedReader(new InputStreamReader(assetManager.open(fileName)));
        String line;
        while ((line = bf.readLine()) != null) {
            stringBuilder.append(line);
        }

    } catch (IOException e) {
        e.printStackTrace();
    }
    return stringBuilder.toString();
}
</code></pre>
<h2 id="urlencoder-&#x4E2D;&#x6587;"><a name="urlencoder-&#x4E2D;&#x6587;" class="anchor-navigation-ex-anchor" href="#urlencoder-&#x4E2D;&#x6587;"><i class="fa fa-link" aria-hidden="true"></i></a>1.15. URLEncoder &#x4E2D;&#x6587;</h2>
<h3 id="&#x5224;&#x65AD;&#x662F;&#x5426;&#x6709;&#x4E2D;&#x6587;"><a name="&#x5224;&#x65AD;&#x662F;&#x5426;&#x6709;&#x4E2D;&#x6587;" class="anchor-navigation-ex-anchor" href="#&#x5224;&#x65AD;&#x662F;&#x5426;&#x6709;&#x4E2D;&#x6587;"><i class="fa fa-link" aria-hidden="true"></i></a>1.15.1. &#x5224;&#x65AD;&#x662F;&#x5426;&#x6709;&#x4E2D;&#x6587;</h3>
<pre><code class="lang-text">URLEncoder.encode(str ,&quot;UTF-8&quot;));

public static boolean isChineseChar(String str){
    boolean temp = false;
    Pattern p=Pattern.compile(&quot;[\u4e00-\u9fa5]&quot;);
    Matcher m=p.matcher(str);
    if(m.find()){
        temp =  true;
    }
    return temp;
}
</code></pre>
<h3 id="&#x6B63;&#x5219;&#x6362;url&#x5B57;&#x7B26;&#x4E32;&#x91CC;&#x9762;&#x7684;&#x6C49;&#x5B57;&#x90E8;&#x5206;"><a name="&#x6B63;&#x5219;&#x6362;url&#x5B57;&#x7B26;&#x4E32;&#x91CC;&#x9762;&#x7684;&#x6C49;&#x5B57;&#x90E8;&#x5206;" class="anchor-navigation-ex-anchor" href="#&#x6B63;&#x5219;&#x6362;url&#x5B57;&#x7B26;&#x4E32;&#x91CC;&#x9762;&#x7684;&#x6C49;&#x5B57;&#x90E8;&#x5206;"><i class="fa fa-link" aria-hidden="true"></i></a>1.15.2. &#x6B63;&#x5219;&#x6362;URL&#x5B57;&#x7B26;&#x4E32;&#x91CC;&#x9762;&#x7684;&#x6C49;&#x5B57;&#x90E8;&#x5206;</h3>
<pre><code class="lang-text">public static String encode(String str, String charset)  {
    Pattern p = Pattern.compile(&quot;[\u4e00-\u9fa5]&quot;);
    Matcher m = p.matcher(str);
    StringBuffer b = new StringBuffer();
    while (m.find()) {
        m.appendReplacement(b, URLEncoder.encode(m.group(0), charset));
    }
    m.appendTail(b);
    return b.toString();
}
</code></pre>
<h2 id="&#x5176;&#x4ED6;"><a name="&#x5176;&#x4ED6;" class="anchor-navigation-ex-anchor" href="#&#x5176;&#x4ED6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16. &#x5176;&#x4ED6;</h2>
<h3 id="&#x5224;&#x65AD;&#x662F;&#x5426;&#x662F;&#x95F0;&#x5E74;"><a name="&#x5224;&#x65AD;&#x662F;&#x5426;&#x662F;&#x95F0;&#x5E74;" class="anchor-navigation-ex-anchor" href="#&#x5224;&#x65AD;&#x662F;&#x5426;&#x662F;&#x95F0;&#x5E74;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.1. &#x5224;&#x65AD;&#x662F;&#x5426;&#x662F;&#x95F0;&#x5E74;</h3>
<pre><code class="lang-text">if (n%400==0 ||n%4==0 &amp;&amp; n%100!=0) {
 //&#x95F0;&#x5E74;
}
</code></pre>
<h3 id="&#x53CC;&#x51FB;&#x9000;&#x51FA;-&#x3001;&#x6309;&#x952E;&#x76D1;&#x542C;"><a name="&#x53CC;&#x51FB;&#x9000;&#x51FA;-&#x3001;&#x6309;&#x952E;&#x76D1;&#x542C;" class="anchor-navigation-ex-anchor" href="#&#x53CC;&#x51FB;&#x9000;&#x51FA;-&#x3001;&#x6309;&#x952E;&#x76D1;&#x542C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.2. &#x53CC;&#x51FB;&#x9000;&#x51FA; &#x3001;&#x6309;&#x952E;&#x76D1;&#x542C;</h3>
<pre><code class="lang-text">private long lastTime = 0 ;
private void exitActivity( ) {
    if (System.currentTimeMillis() - lastTime &lt; 2000L) {
        this.finish() ;
    } else {
        lastTime = System.currentTimeMillis() ;
        toastMsg(&quot;&#x518D;&#x6B21;&#x70B9;&#x51FB;&#x9000;&#x51FA;&quot;);
    }
}

KeyEvent.KEYCODE_BACK         //     &#x8FD4;&#x56DE;&#x952E;
KeyEvent.KEYCODE_VOLUME_UP   // &#x97F3;&#x91CF;&#x589E;&#x52A0;&#x952E;
KeyEvent.KEYCODE_VOLUME_DOWN // &#x97F3;&#x91CF;&#x51CF;&#x5C0F;&#x952E;
KeyEvent.KEYCODE_VOLUME_MUTE //&#x626C;&#x58F0;&#x5668;&#x9759;&#x97F3;&#x952E;
KeyEvent.KEYCODE_MENU         // &#x83DC;&#x5355;&#x952E;
KeyEvent.KEYCODE_CALL         // &#x62E8;&#x53F7;&#x952E;
KeyEvent.KEYCODE_ENDCALL        // &#x6302;&#x673A;&#x952E;
KeyEvent.KEYCODE_HEADSETHOOK   // &#x8033;&#x673A;&#x952E;
KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE // &#x64AD;&#x653E; / &#x6682;&#x505C;
KeyEvent.KEYCODE_MEDIA_STOP   // &#x591A;&#x5A92;&#x4F53;&#x952E; &#x505C;&#x6B62;
KeyEvent.KEYCODE_MEDIA_PAUSE// &#x591A;&#x5A92;&#x4F53;&#x952E; &#x6682;&#x505C;
</code></pre>
<h3 id="&#x4E0D;&#x5B9A;&#x53C2;&#x6570;"><a name="&#x4E0D;&#x5B9A;&#x53C2;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x4E0D;&#x5B9A;&#x53C2;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.3. &#x4E0D;&#x5B9A;&#x53C2;&#x6570;</h3>
<pre><code class="lang-text">//&#x76F8;&#x5F53;&#x4E8E;&#x662F;&#x4E8C;&#x7EF4;&#x6570;&#x7EC4;&#xFF0C;arg&#x4E2D;&#x6BCF;&#x4E2A;&#x7A7A;&#x95F4;&#x4FDD;&#x5B58;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;
public void method(int[]...arg);
</code></pre>
<h3 id="&#x5012;&#x8BA1;&#x65F6;"><a name="&#x5012;&#x8BA1;&#x65F6;" class="anchor-navigation-ex-anchor" href="#&#x5012;&#x8BA1;&#x65F6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.4. &#x5012;&#x8BA1;&#x65F6;</h3>
<pre><code class="lang-text">&#x7B80;&#x5355;&#x573A;&#x666F;&#x5C31;&#x4F7F;&#x7528;Chronometer&#x3002;
&#x590D;&#x6742;&#x573A;&#x666F;&#x4F7F;&#x7528;&#x7F51;&#x4E0A;&#x5F88;&#x591A;&#x5F00;&#x6E90;&#x7684;&#xFF0C;&#x6BD4;&#x5982;&#x5C0F;&#x7C73;&#x65F6;&#x949F;&#x3001;&#x9524;&#x5B50;&#x65F6;&#x949F;&#x4E2D;&#x7684;&#x5B9E;&#x73B0;&#x601D;&#x8DEF;&#x3002;
</code></pre>
<h3 id="&#x9009;&#x4E2D;&#x6548;&#x679C;"><a name="&#x9009;&#x4E2D;&#x6548;&#x679C;" class="anchor-navigation-ex-anchor" href="#&#x9009;&#x4E2D;&#x6548;&#x679C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.5. &#x9009;&#x4E2D;&#x6548;&#x679C;</h3>
<p>xxx.setSelected(false);</p>
<pre><code class="lang-text"> &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;selector xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
    &lt;item android:drawable=&quot;@drawable/checkout_middle&quot; android:state_selected=&quot;true&quot;/&gt;
    &lt;item android:drawable=&quot;@drawable/call_grren&quot; android:state_focused=&quot;false&quot; android:state_pressed=&quot;true&quot;/&gt;
    &lt;item android:drawable=&quot;@drawable/check_out_left&quot;/&gt;
&lt;/selector&gt;
</code></pre>
<h3 id="&#x70B9;&#x51FB;&#x6548;&#x679C;"><a name="&#x70B9;&#x51FB;&#x6548;&#x679C;" class="anchor-navigation-ex-anchor" href="#&#x70B9;&#x51FB;&#x6548;&#x679C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.6. &#x70B9;&#x51FB;&#x6548;&#x679C;</h3>
<pre><code class="lang-text">&#x65B9;&#x6CD5;&#x4E00;&#xFF0C;&#x53EF;&#x4EE5;&#x91C7;&#x53D6; xml &#x914D;&#x7F6E;&#x7684;&#x65B9;&#x5F0F;&#x3002;
&#x65B9;&#x6CD5;&#x4E8C;&#xFF0C;&#x53EF;&#x4EE5;&#x91C7;&#x7528; Drawable &#x6765;&#x5B9E;&#x73B0; &#x3002;
&#x91CD;&#x5199; ImageView &#x7684;&#x65B9;&#x6CD5; 
public boolean onTouchEvent(MotionEvent event) {
   // &#x4E24;&#x4E2A; getDrawable &#x53D6;&#x5F97;&#x7684;&#x5BF9;&#x8C61;, &#x9700;&#x8981;&#x7528; mutate &#x8BBE;&#x7F6E;&#x4E00;&#x4E0B;
    Drawable drawable = getDrawable();
    if(drawable==null){
        return super.onTouchEvent(event);
    }
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            drawable.mutate().setColorFilter(Color.GRAY,  PorterDuff.Mode.MULTIPLY);
            break;

        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            drawable.mutate().clearColorFilter();
            performClick();
            break;
    }
    return super.onTouchEvent(event);
}

// &#x8865;&#x5145; mutate &#x7528;&#x6CD5;
&#x5982;&#x679C;&#x591A;&#x4E2A;&#x63A7;&#x4EF6;&#x4F7F;&#x7528;&#x540C;&#x4E00;&#x4E2A; Drawable &#xFF0C;
&#x5982;&#x679C;&#x5176;&#x4E2D;&#x4E00;&#x4E2A;&#x63A7;&#x4EF6;&#x7684; Drawable &#x53D1;&#x751F;&#x6539;&#x53D8;&#xFF0C;&#x5176;&#x4ED6;&#x6240;&#x6709;&#x7684;Drawable&#x90FD;&#x4F1A;&#x53D1;&#x751F;&#x6539;&#x53D8;&#x3002;
&#x5982;&#x679C;&#x4F7F;&#x7528;Drawable.mutate()&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x4ECE; Drawable &#x91CC;&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;&#x4E0D;&#x53EF;&#x53D8;&#x7684;&#x5B9E;&#x4F8B;&#xFF0C;
&#x90A3;&#x4E48;&#x5F53;&#x8FD9;&#x4E2A;Drawable&#x53D1;&#x751F;&#x6539;&#x53D8;&#x65F6;&#xFF0C;&#x4E0D;&#x4F1A;&#x5BFC;&#x81F4;&#x5176;&#x4ED6;&#x7684;Drawable&#x53D1;&#x751F;&#x6539;&#x53D8;&#x3002;
</code></pre>
<h3 id="&#x5168;&#x5C4F;&#x3001;&#x53BB;&#x6389;&#x6807;&#x9898;&#x680F;"><a name="&#x5168;&#x5C4F;&#x3001;&#x53BB;&#x6389;&#x6807;&#x9898;&#x680F;" class="anchor-navigation-ex-anchor" href="#&#x5168;&#x5C4F;&#x3001;&#x53BB;&#x6389;&#x6807;&#x9898;&#x680F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.7. &#x5168;&#x5C4F;&#x3001;&#x53BB;&#x6389;&#x6807;&#x9898;&#x680F;</h3>
<pre><code class="lang-text">//&#x5728;setContentView&#x4E4B;&#x524D;&#x8BBE;&#x7F6E;
requestWindowFeature(Window.FEATURE_NO_TITLE); //Activity
supportRequestWindowFeature(Window.FEATURE_NO_TITLE); // ok  AppCompatDialog

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

//extends AppCompatActivity
android:theme=&quot;@style/Theme.AppCompat.Light.NoActionBar&quot;

getSupportActionBar().hide();
</code></pre>
<h3 id="&#x542F;&#x52A8;&#x9ED8;&#x8BA4;&#x6D4F;&#x89C8;&#x5668;"><a name="&#x542F;&#x52A8;&#x9ED8;&#x8BA4;&#x6D4F;&#x89C8;&#x5668;" class="anchor-navigation-ex-anchor" href="#&#x542F;&#x52A8;&#x9ED8;&#x8BA4;&#x6D4F;&#x89C8;&#x5668;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.8. &#x542F;&#x52A8;&#x9ED8;&#x8BA4;&#x6D4F;&#x89C8;&#x5668;</h3>
<pre><code class="lang-text">Intent intent =newIntent();
intent.setAction(&quot;android.intent.action.VIEW&quot;);
Uri content_url =Uri.parse(&quot;http://www.xxx.com&quot;);
intent.setData(content_url);
startActivity(intent);
</code></pre>
<h3 id="&#x542F;&#x52A8;&#x7B2C;&#x4E09;&#x65B9;&#x5E94;&#x7528;"><a name="&#x542F;&#x52A8;&#x7B2C;&#x4E09;&#x65B9;&#x5E94;&#x7528;" class="anchor-navigation-ex-anchor" href="#&#x542F;&#x52A8;&#x7B2C;&#x4E09;&#x65B9;&#x5E94;&#x7528;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.9. &#x542F;&#x52A8;&#x7B2C;&#x4E09;&#x65B9;&#x5E94;&#x7528;</h3>
<pre><code class="lang-text">PackageManager pm = this.getPackageManager();
Intent intent = pm.getLaunchIntentForPackage(&quot;xxx.&#x5305;&#x540D;.xxx&quot;);
try {
    startActivity(intent);
} catch (Exception e) {
    //&#x8BF7;&#x5148;&#x5B89;&#x88C5;
}
</code></pre>
<h3 id="&#x7CFB;&#x7EDF;&#x5206;&#x4EAB;&#x529F;&#x80FD;"><a name="&#x7CFB;&#x7EDF;&#x5206;&#x4EAB;&#x529F;&#x80FD;" class="anchor-navigation-ex-anchor" href="#&#x7CFB;&#x7EDF;&#x5206;&#x4EAB;&#x529F;&#x80FD;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.10. &#x7CFB;&#x7EDF;&#x5206;&#x4EAB;&#x529F;&#x80FD;</h3>
<pre><code class="lang-text">Intent wechatIntent = new Intent(Intent.ACTION_SEND);
wechatIntent.setPackage(&quot;com.tencent.mm&quot;);//&#x5FAE;&#x4FE1;
wechatIntent.setType(&quot;text/plain&quot;);
wechatIntent.putExtra(Intent.EXTRA_TEXT,  &quot;hello world&quot;);
try{
    context. startActivity(wechatIntent);
}catch (Exception e){
    //&#x8BF7;&#x5148;&#x5B89;&#x88C5;&#x5FAE;&#x4FE1;
}
</code></pre>
<h3 id="&#x4F7F;&#x7528;&#x81EA;&#x5B9A;&#x4E49;&#x5B57;&#x4F53;"><a name="&#x4F7F;&#x7528;&#x81EA;&#x5B9A;&#x4E49;&#x5B57;&#x4F53;" class="anchor-navigation-ex-anchor" href="#&#x4F7F;&#x7528;&#x81EA;&#x5B9A;&#x4E49;&#x5B57;&#x4F53;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.11. &#x4F7F;&#x7528;&#x81EA;&#x5B9A;&#x4E49;&#x5B57;&#x4F53;</h3>
<pre><code class="lang-text">AssetManager mgr = getAssets();
Typeface tf = Typeface.createFromAsset(mgr, &quot;fonts/2.TTF&quot;);// &#x6587;&#x4EF6;&#x5728;assets/fonts&#x76EE;&#x5F55;&#x4E0B;
textView.setTypeface(tf);
</code></pre>
<h3 id="xml&#x89E3;&#x6790;"><a name="xml&#x89E3;&#x6790;" class="anchor-navigation-ex-anchor" href="#xml&#x89E3;&#x6790;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.12. XML&#x89E3;&#x6790;</h3>
<pre><code class="lang-text">SAX&#xFF1A;Simple API for XML&#x3002; &#x76F8;&#x6BD4;&#x4E8E;DOM&#xFF0C;SAX&#x662F;&#x4E00;&#x79CD;&#x901F;&#x5EA6;&#x66F4;&#x5FEB;&#xFF0C;&#x66F4;&#x6709;&#x6548;&#x7684;&#x65B9;&#x6CD5;&#x3002;&#x5B83;&#x9010;&#x884C;&#x626B;&#x63CF;&#x6587;&#x6863;&#xFF0C;&#x4E00;&#x8FB9;&#x626B;&#x63CF;&#x4E00;&#x8FB9;&#x89E3;&#x6790;&#x3002; 
&#x4E0D;&#x7528;&#x5B9E;&#x73B0;&#x8C03;&#x5165;&#x6574;&#x4E2A;&#x6587;&#x6863;&#xFF0C;&#x5360;&#x7528;&#x8D44;&#x6E90;&#x5C11;&#x3002;&#x5C24;&#x5176;&#x5728;&#x5D4C;&#x5165;&#x5F0F;&#x73AF;&#x5883;&#x4E2D;&#xFF0C;&#x5982;android&#xFF0C;&#x6781;&#x529B;&#x63A8;&#x8350;&#x4F7F;&#x7528;SAX&#x89E3;&#x6790;&#x3002;
</code></pre>
<h3 id="&#x590D;&#x5236;&#x7C98;&#x8D34;"><a name="&#x590D;&#x5236;&#x7C98;&#x8D34;" class="anchor-navigation-ex-anchor" href="#&#x590D;&#x5236;&#x7C98;&#x8D34;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.13. &#x590D;&#x5236;&#x7C98;&#x8D34;</h3>
<pre><code class="lang-text">// &#x5F97;&#x5230;&#x526A;&#x8D34;&#x677F;&#x7BA1;&#x7406;&#x5668;
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
//&#x590D;&#x5236;
cmb.setText( msg);
// &#x7C98;&#x8D34;
String msg=cmb.getText().toString()
</code></pre>
<h3 id="&#x9632;&#x6B62;-toast-&#x91CD;&#x590D;&#x63D0;&#x793A;"><a name="&#x9632;&#x6B62;-toast-&#x91CD;&#x590D;&#x63D0;&#x793A;" class="anchor-navigation-ex-anchor" href="#&#x9632;&#x6B62;-toast-&#x91CD;&#x590D;&#x63D0;&#x793A;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.14. &#x9632;&#x6B62; Toast &#x91CD;&#x590D;&#x63D0;&#x793A;</h3>
<pre><code class="lang-text">private static Toast mToast;
public void showMsg(Context context, String msg) {
    if (mToast == null) {
        mToast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
    } else {
        //&#x76F4;&#x63A5;&#x8BBE;&#x7F6E;&#xFF0C;&#x4E0D;&#x7528;&#x91CD;&#x590D;&#x521B;&#x5EFA;
        mToast.setText(msg);
    }
    mToast.show();
}
</code></pre>
<h3 id="performclick"><a name="performclick" class="anchor-navigation-ex-anchor" href="#performclick"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.15. performClick</h3>
<p>Custom view FloatingforView overrides onTouchEvent but not performClick less...</p>
<pre><code class="lang-text">case MotionEvent.ACTION_UP:
               performClick();
               break;

@Override
public boolean performClick() {
    return super.performClick();
}
</code></pre>
<h3 id="&#x4FDD;&#x5B58;&#x63A7;&#x4EF6;&#x622A;&#x56FE;"><a name="&#x4FDD;&#x5B58;&#x63A7;&#x4EF6;&#x622A;&#x56FE;" class="anchor-navigation-ex-anchor" href="#&#x4FDD;&#x5B58;&#x63A7;&#x4EF6;&#x622A;&#x56FE;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.16. &#x4FDD;&#x5B58;&#x63A7;&#x4EF6;&#x622A;&#x56FE;</h3>
<pre><code class="lang-text">public static Bitmap saveViewBitmap(View view) {
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache(true);
    Bitmap cacheBitmap = view.getDrawingCache(true);
    Bitmap destBitmap = Bitmap.createBitmap(cacheBitmap);
    cacheBitmap.recycle();
    view.setDrawingCacheEnabled(false);
    return destBitmap;
}
</code></pre>
<h3 id="&#x56FE;&#x7247;&#x8F6C;byte"><a name="&#x56FE;&#x7247;&#x8F6C;byte" class="anchor-navigation-ex-anchor" href="#&#x56FE;&#x7247;&#x8F6C;byte"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.17. &#x56FE;&#x7247;&#x8F6C;byte[]</h3>
<pre><code class="lang-text">ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] array = stream.toByteArray();
</code></pre>
<h3 id="&#x56FE;&#x7247;&#x8F6C;base64"><a name="&#x56FE;&#x7247;&#x8F6C;base64" class="anchor-navigation-ex-anchor" href="#&#x56FE;&#x7247;&#x8F6C;base64"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.18. &#x56FE;&#x7247;&#x8F6C;Base64</h3>
<pre><code class="lang-text">ByteArrayOutputStream bStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, bStream);
byte[] bytes = bStream.toByteArray();
return Base64.encodeToString(bytes, Base64.DEFAULT);
</code></pre>
<h3 id="&#x83B7;&#x53D6;-bitmap-&#x7F29;&#x7565;&#x56FE;"><a name="&#x83B7;&#x53D6;-bitmap-&#x7F29;&#x7565;&#x56FE;" class="anchor-navigation-ex-anchor" href="#&#x83B7;&#x53D6;-bitmap-&#x7F29;&#x7565;&#x56FE;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.19. &#x83B7;&#x53D6; Bitmap &#x7F29;&#x7565;&#x56FE;</h3>
<pre><code class="lang-text">public Bitmap getImageThumbnail(Bitmap bitmap0 ,  int width, int height) {
    Bitmap bitmap = ThumbnailUtils.extractThumbnail(bitmap0, width, height,  ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
    return bitmap;
}
</code></pre>
<h3 id="&#x5360;&#x4F4D;&#x7B26;"><a name="&#x5360;&#x4F4D;&#x7B26;" class="anchor-navigation-ex-anchor" href="#&#x5360;&#x4F4D;&#x7B26;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.20. &#x5360;&#x4F4D;&#x7B26;</h3>
<pre><code class="lang-text">&lt;string name=&quot;string_test_1&quot;&gt;&#x5B66;&#x53F7;&#xFF1A;%1$d ;&#x59D3;&#x540D;&#xFF1A;%2$s ;&#x6210;&#x7EE9;&#xFF1A;%3$.2f&lt;/string&gt;
String result = String.format(testStr,1001,&quot;&#x5F20;&#x4E09;&quot;,9.235);

%N&#x4EE3;&#x8868;&#x7B2C;N&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x5982;%3&#x4EE3;&#x8868;&#x7684;&#x662F;&#x7B2C;&#x4E09;&#x4E2A;&#x53C2;&#x6570;&#xFF1B;
$&#x662F;&#x7ED3;&#x675F;&#x7B26;&#xFF1B;
d/s/.2f&#x4EE3;&#x8868;&#x7684;&#x662F;&#x6574;&#x6570;/&#x5B57;&#x7B26;&#x4E32;/&#x4FDD;&#x7559;2&#x4F4D;&#x5C0F;&#x6570;&#x70B9;&#x7684;&#x6D6E;&#x70B9;&#x6570;


xml &#x4E2D;&#x914D;&#x7F6E;&#x5360;&#x4F4D;&#x7B26;
 &lt;string name=&quot;lowBatteryInfo&quot;&gt;&#x6CE8;&#x610F;&#xFF1A;&#x5F53;&#x524D;&#x7535;&#x91CF;&#x4F4E;&#xFF0C;&#x53EA;&#x5269; %1$.4s %% &#xFF01;&#x8BF7;&#x5C3D;&#x5FEB;&#x8FD4;&#x822A;&#xFF01;&#xFF01;&#xFF01;&lt;/string&gt;
float percentV= 19.12342342342f;
String msg1 =getString(R.string.lowBatteryInfo) ;
String alertInfo  = String.format(Locale.getDefault() , msg1 , String.valueOf(percentV) ) ;
Log.i(&quot;aivin&quot; ,&quot;alertInfo=&quot;+alertInfo); // alertInfo=&#x6CE8;&#x610F;&#xFF1A;&#x5F53;&#x524D;&#x7535;&#x91CF;&#x4F4E;&#xFF0C;&#x53EA;&#x5269; 19.1 % &#xFF01;&#x8BF7;&#x5C3D;&#x5FEB;&#x8FD4;&#x822A;&#xFF01;&#xFF01;&#xFF01;
</code></pre>
<h3 id="&#x56FE;&#x7247;&#x5E73;&#x94FA;"><a name="&#x56FE;&#x7247;&#x5E73;&#x94FA;" class="anchor-navigation-ex-anchor" href="#&#x56FE;&#x7247;&#x5E73;&#x94FA;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.21. &#x56FE;&#x7247;&#x5E73;&#x94FA;</h3>
<pre><code class="lang-text">&lt;bitmap xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:src=&quot;@drawable/redline_vertical&quot;
    android:tileMode=&quot;repeat&quot; /&gt;
android:background=&quot;@drawable/redline_verticalbitmap&quot;
</code></pre>
<h3 id="&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x914D;&#x7F6E;"><a name="&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x914D;&#x7F6E;" class="anchor-navigation-ex-anchor" href="#&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x914D;&#x7F6E;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.22. &#x73AF;&#x5883;&#x53D8;&#x91CF;&#x914D;&#x7F6E;</h3>
<pre><code class="lang-text">1&#x3001;&#x5EFA;-&gt;&#x53D8;&#x91CF;&#x540D;&#xFF1A;JAVA_HOME &#x53D8;&#x91CF;&#x503C;&#xFF1A;D:/Java/jdk1.6.0_12(&#x8FD9;&#x53EA;&#x662F;&#x6211;&#x7684;JDK&#x5B89;&#x88C5;&#x8DEF;&#x5F84;)
2&#x3001;&#x7F16;&#x8F91;-&gt;&#x53D8;&#x91CF;&#x540D;&#xFF1A;Path &#x5728;&#x53D8;&#x91CF;&#x503C;&#x7684;&#x6700;&#x524D;&#x9762;&#x52A0;&#x4E0A;&#xFF1A;%JAVA_HOME%/bin;%JAVA_HOME%/jre/bin
3&#x3001;&#x65B0;&#x5EFA;-&gt;&#x53D8;&#x91CF;&#x540D;&#xFF1A;CLASSPATH &#x53D8;&#x91CF;&#x503C;&#xFF1A;.;%JAVA_HOME%/lib;%JAVA_HOME%/lib/dt.jar;%JAVA_HOME%/lib/tools.jar
&#x5206;&#x522B;&#x8F93;&#x5165;java&#xFF0C;javac&#xFF0C;java -version &#x547D;&#x4EE4;&#x6D4B;&#x8BD5;&#x662F;&#x5426;&#x914D;&#x7F6E;&#x6210;&#x529F;
SDK&#x89E3;&#x538B;&#xFF0C;&#x628A;&#x89E3;&#x538B;&#x540E;&#x6587;&#x4EF6;&#x5939;&#x7684;tools&#x76EE;&#x5F55;&#x6DFB;&#x52A0;&#x5230;&#x73AF;&#x5883;&#x53D8;&#x91CF;path&#x4E2D;

&#x67E5;&#x770B;&#x914D;&#x7F6E;&#x597D;&#x7684;&#x53D8;&#x91CF;&#x3001;jdk&#x5F53;&#x524D;&#x8DEF;&#x5F84;&#x3001;jdk&#x5B89;&#x88C5;&#x8DEF;&#x5F84;
echO  %JAVA_HOME%  //&#x5B57;&#x6BCD;o 

java javac &#x663E;&#x793A;&#x7248;&#x672C;&#x6B63;&#x5E38;&#xFF0C;&#x4E5F;&#x80FD;&#x591F;&#x7F16;&#x8BD1;&#x6210;&#x529F;&#xFF0C;&#x8FD0;&#x884C;java &#x7684;&#x65F6;&#x5019;&#x51FA;&#x73B0;&#x627E;&#x4E0D;&#x5230;&#x7C7B;&#x7684;&#x9519;&#x8BEF;&#x3002; &#x5728;classpath&#x4E2D;&#x6DFB;&#x52A0;  .;  &#x5373;&#x53EF;&#x89E3;&#x51B3;&#x3002;

//JDK&#x7248;&#x672C;&#x66F4;&#x6539;&#x540E;&#xFF0C;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x4E0D;&#x751F;&#x6548;
&#x5220;&#x9664; C:\Windows\System32&#x76EE;&#x5F55;&#x4E0B; java.exe&#x3001;javaw.exe&#x3001;javaws.exe &#x4E09;&#x4E2A;&#x6587;&#x4EF6;&#x3002;
&#x5220;&#x9664;Path&#x4E2D; C:\ProgramData\Oracle\Java\javapath &#x914D;&#x7F6E;
</code></pre>
<h3 id="bytebuffer&#x76F8;&#x5173;"><a name="bytebuffer&#x76F8;&#x5173;" class="anchor-navigation-ex-anchor" href="#bytebuffer&#x76F8;&#x5173;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16.23. ByteBuffer&#x76F8;&#x5173;</h3>
<pre><code class="lang-text">// &#x6DF1;&#x5EA6;&#x514B;&#x9686;ByteBuffer
private  ByteBuffer deepCloneByteBuffer(ByteBuffer original) {
    ByteBuffer clone = ByteBuffer.allocate(original.capacity());
    original.rewind();
    // &#x7528;put&#x63A5;&#x53E3;&#xFF0C;&#x624D;&#x4F1A;&#x628A;byte&#x6570;&#x7EC4;&#x7684;&#x5185;&#x5BB9;&#x62F7;&#x8D1D;&#x5230;ByteBuffer&#x4E2D;
    clone.put(original);
    original.rewind();
    clone.flip();
    return clone;
}


//java.nio.ByteBuffer&#x53D8;&#x91CF;&#x89E3;&#x91CA;
int position 
&#x8BFB;&#x5199;&#x4F4D;&#x7F6E;&#xFF0C;&#x8868;&#x793A;&#x5F53;&#x524D;&#x8FDB;&#x884C;&#x8BFB;&#x5199;&#x64CD;&#x4F5C;&#x65F6;&#x7684;&#x4F4D;&#x7F6E;&#x3002;
position&#x7684;&#x4F4D;&#x7F6E;&#x4F1A;&#x968F;&#x7740;&#x6570;&#x636E;&#x7684;&#x5199;&#x5165;&#x800C;&#x79FB;&#x6216;&#x8005;&#x8BFB;&#x53D6;&#x4E00;&#x4E2A;&#x5B57;&#x8282;&#x4E00;&#x4E2A;&#x5B57;&#x8282;&#x7684;&#x79FB;&#x52A8;&#x3002;
&#x6BD4;&#x5982;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;byte&#x7C7B;&#x578B;&#x7684;&#x6570;&#x636E;position&#x4F1A;+1, &#x6DFB;&#x52A0;&#x4E00;&#x4E2A;int&#x7C7B;&#x578B;&#x7684;&#x6570;&#x636E;position&#x4F1A;+4

int limit 
&#x8BFB;&#x5199;&#x9650;&#x5236;, &#x7F13;&#x51B2;&#x533A;&#x53EF;&#x4EE5;&#x8FDB;&#x884C;&#x8BFB;&#x5199;&#x7684;&#x8303;&#x56F4;&#x7684;&#x6700;&#x5927;&#x503C;&#x3002;

int capacity 
&#x5BB9;&#x91CF;&#xFF0C;&#x5B83;&#x7684;&#x503C;&#x662F;&#x5728;&#x521B;&#x5EFA;&#x7F13;&#x51B2;&#x533A;&#x7684;&#x65F6;&#x5019;&#x6307;&#x5B9A;&#x7684;&#xFF0C;&#x8BBE;&#x5B9A;&#x540E;&#x65E0;&#x6CD5;&#x5BF9;&#x5176;&#x8FDB;&#x884C;&#x4FEE;&#x6539;&#x3002; 

int mark 
&#x4E34;&#x65F6;&#x6807;&#x8BB0;&#x53D8;&#x91CF;&#xFF0C;&#x7528;&#x6765;&#x5B58;&#x50A8; postion&#x7684;&#x3002;


//&#x5E38;&#x7528;&#x65B9;&#x6CD5;
ByteBuffer= allocate(int capacity)  &#x5206;&#x914D;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x5B57;&#x8282;&#x7F13;&#x51B2;&#x533A;&#x3002;
ByteBuffer= allocateDirect(int capacity)  &#x5206;&#x914D;&#x65B0;&#x7684;&#x76F4;&#x63A5;&#x5B57;&#x8282;&#x7F13;&#x51B2;&#x533A;&#x3002;
int =position()  &#x83B7;&#x53D6;position
Buffer= position(10) ; &#x8BBE;&#x7F6E; position
int =limit() &#x83B7;&#x53D6;limit
Buffer =limit(10) &#x8BBE;&#x7F6E;limit
int =capacity() &#x83B7;&#x53D6;capacity
byte[] = array()  
Buffer= flip() &#x628A;limit&#x8BBE;&#x4E3A;&#x5F53;&#x524D;position&#xFF0C;&#x628A;position&#x8BBE;&#x4E3A;0
Buffer= mark() &#x5C06;&#x5B58;&#x50A8;&#x5F53;&#x524D;position&#x7684;&#x503C;&#xFF0C;&#x7B49;&#x4E0B;&#x6B21;&#x8C03;&#x7528;reset()&#x65B9;&#x6CD5;&#x65F6;&#xFF0C;&#x4F1A;&#x8BBE;&#x5B9A;position&#x7684;&#x503C;&#x4E3A;&#x4E4B;&#x524D;&#x7684;&#x6807;&#x8BB0;&#x503C;&#xFF1B;
Buffer= reset()  
Buffer= rewind() &#x628A;position&#x8BBE;&#x4E3A;0&#xFF0C;limit&#x4E0D;&#x53D8;
Buffer= clear() &#x628A;position&#x8BBE;&#x4E3A;0&#xFF0C;&#x628A;limit&#x8BBE;&#x4E3A;capacity&#x3002;&#x5E76;&#x4E0D;&#x662F;&#x6E05;&#x7A7A;&#x5185;&#x5BB9;

ByteBuffer= compact() 
&#x5C06; position &#x4E0E; limit&#x4E4B;&#x95F4;&#x7684;&#x6570;&#x636E;&#x590D;&#x5236;&#x5230;buffer&#x7684;&#x5F00;&#x59CB;&#x4F4D;&#x7F6E;&#xFF0C;  
&#x82E5; position &#x4E0E;limit &#x4E4B;&#x95F4;&#x6CA1;&#x6709;&#x6570;&#x636E;&#x7684;&#x8BDD;&#x53D1;&#xFF0C;&#x5C31;&#x4E0D;&#x4F1A;&#x8FDB;&#x884C;&#x590D;&#x5236; &#x3002; 
&#x5176;&#x5B9E;&#x5C31;&#x662F;&#x5220;&#x9664;&#x5DF2;&#x8BFB;&#x8FC7;&#x7684;&#x6570;&#x636E;&#x590D;&#x5236;&#x540E; position  = limit -position,limit = capacity  &#x3002;

ByteBuffer=  wrap(byte[] array,  int offset,  int length) limit &#x7B49;&#x4E8E; offset
ByteBuffer=  wrap(byte[] array ) &#x8FD9;&#x4E2A;&#x7F13;&#x51B2;&#x533A;&#x7684;&#x6570;&#x636E;&#x4F1A;&#x5B58;&#x653E;&#x5728;byte&#x6570;&#x7EC4;&#x4E2D;&#xFF0C;bytes&#x6570;&#x7EC4;&#x6216;buff&#x7F13;&#x51B2;&#x533A;&#x4EFB;&#x4F55;&#x4E00;&#x65B9;&#x4E2D;&#x6570;&#x636E;&#x7684;&#x6539;&#x52A8;&#x90FD;&#x4F1A;&#x5F71;&#x54CD;&#x53E6;&#x4E00;&#x65B9;&#x3002;
ByteBuffer= slice() &#x8FD4;&#x56DE;&#x539F;ByteBuffer&#x7684;&#x4E00;&#x4E2A;&#x955C;&#x50CF;&#xFF0C;&#x6240;&#x6709;&#x6539;&#x53D8;&#x4E92;&#x76F8;&#x53EF;&#x89C1;
ByteBuffe=r put(byte[] src) &#x5C06;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;&#x5199;&#x5165;
ByteBuffer= put(byte b) &#x5C06;&#x4E00;&#x4E2A;byte&#x5199;&#x5165;&#xFF0C;postion+1
ByteBuffer= put(int index, byte b) &#x628A;src&#x4E2D;&#x53EF;&#x8BFB;&#x7684;&#x90E8;&#x5206;&#xFF08;&#x4E5F;&#x5C31;&#x662F;position&#x5230;limit&#xFF09;&#x5199;&#x5165;&#x6B64;byteBuffer
ByteBuffer =get(byte[] dst) &#x5C06;&#x5185;&#x5BB9;&#x8BFB;&#x53D6;&#x5230;&#x7136;&#x540E;&#x653E;&#x5230; dst&#x4E2D;
byte=  get() &#x8BFB;&#x53D6;&#x4E00;&#x4E2A;byte
</code></pre>
<h2 id="&#x5982;&#x4F55;&#x5224;&#x65AD;&#x4E00;&#x4E2A;-app-&#x5728;&#x524D;&#x53F0;&#x8FD8;&#x662F;&#x540E;&#x53F0;"><a name="&#x5982;&#x4F55;&#x5224;&#x65AD;&#x4E00;&#x4E2A;-app-&#x5728;&#x524D;&#x53F0;&#x8FD8;&#x662F;&#x540E;&#x53F0;" class="anchor-navigation-ex-anchor" href="#&#x5982;&#x4F55;&#x5224;&#x65AD;&#x4E00;&#x4E2A;-app-&#x5728;&#x524D;&#x53F0;&#x8FD8;&#x662F;&#x540E;&#x53F0;"><i class="fa fa-link" aria-hidden="true"></i></a>1.17. &#x5982;&#x4F55;&#x5224;&#x65AD;&#x4E00;&#x4E2A; APP &#x5728;&#x524D;&#x53F0;&#x8FD8;&#x662F;&#x540E;&#x53F0;</h2>
<p>&#x501F;&#x7528;&#x7CFB;&#x7EDF; ActivityLifecycleCallbacks &#x7684;&#x56DE;&#x8C03;&#x6765;&#x8FDB;&#x884C;&#x5224;&#x65AD;&#x3002;
&#x8FDB;&#x5165;&#x540E;&#x53F0;&#x540E;&#xFF0C;&#x6709;&#x4E00;&#x4E9B;&#x673A;&#x578B;&#x8C8C;&#x4F3C;&#x5F39;&#x4E0D;&#x51FA;toast&#xFF0C;&#x6BD4;&#x5982;&#x534E;&#x4E3A;M3 &#x3002;
&#x6682;&#x65F6;&#x6CA1;&#x627E;&#x5230;&#x89E3;&#x51B3;&#x529E;&#x6CD5;&#xFF0C;&#x6211;&#x8BD5;&#x8FC7;&#x4E00;&#x4E9B;&#x94F6;&#x884C;&#x7684;APP &#x548C;&#x6240;&#x5F97;&#x7A0E;APP&#xFF0C;&#x540C;&#x6837;&#x4E5F;&#x5F39;&#x4E0D;&#x51FA;&#x6765;&#x3002;</p>
<pre><code class="lang-text"> // &#x539F;&#x7406;&#xFF1A;&#x7A0B;&#x5E8F;&#x4E2D;&#x4EFB;&#x4F55;&#x4E00;&#x4E2A;activity&#x5904;&#x4E8E;&#x540E;&#x53F0;&#x65F6;(onStope)&#x90FD;&#x5C06;&#x89E6;&#x53D1;&#x63D0;&#x9192;&#x3002; 
 // &#x6240;&#x4EE5;&#xFF0C;&#x5982;&#x679C;&#x9876;&#x5C42;activity&#x4E2D;onStope&#x65B9;&#x6CD5;&#x88AB;&#x6267;&#x884C;&#xFF0C;&#x5219;&#x8BA4;&#x4E3A;&#x7A0B;&#x5E8F;&#x5904;&#x4E8E;&#x540E;&#x53F0;&#x3002;
public class MyAppLifecycleHandler implements Application.ActivityLifecycleCallbacks {
    private int started = 0;
    private int stopped = 0;
    private String lastActivitName ;
    private boolean flag = true;

    public MyAppLifecycleHandler(String name){
        lastActivitName= name ;
    }

    @Override
    public void onActivityCreated( ... ) {  }

    @Override
    public void onActivitySaveInstanceState( ... ) {  }

    @Override
    public void onActivityResumed(Activity activity) {  }

    @Override
    public void onActivityPaused(Activity activity) {  }

    @Override
    public void onActivityStarted(Activity activity) {
        ++started;
    }

    @Override
    public void onActivityStopped(final Activity activity) {
        ++stopped;
        if (!isApplicationInBackground()){
            return;
        }

        flag = true;
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                if ( flag ) {
                    Toast.makeText(activity, &quot;WkPlayer&#x88AB;&#x5207;&#x6362;&#x81F3;&#x540E;&#x53F0;&quot;, Toast.LENGTH_SHORT).show();
                }
            }
            // &#x5EF6;&#x65F6;&#x7684;&#x4F5C;&#x7528;&#x662F;&#x7528;&#x6765;&#x7B49;&#x5F85;&#x4E00;&#x4E0B;&#xFF0C;&#x770B; onActivityDestroyed &#x662F;&#x5426;&#x88AB;&#x6267;&#x884C;&#x4E86;&#x3002;
        } ,500) ;
    }

    @Override
    public void onActivityDestroyed(Activity activity) {
        if (lastActivitName.contains(activity.getClass().getSimpleName())) {
            flag = false;
        }
    }

    private boolean isApplicationInBackground() {
        return started == stopped;
    }
}
// Application &#x4E2D;&#x8C03;&#x7528;
MyAppLifecycleHandler lifecycleHandler = new MyAppLifecycleHandler( FileExplorerActivity.class.getSimpleName() ) ;
unregisterActivityLifecycleCallbacks(lifecycleHandler);
registerActivityLifecycleCallbacks(  lifecycleHandler ) ;
</code></pre>
<h1 id="&#x76AE;&#x80A4;&#x66F4;&#x6362;-&#x3001;&#x66F4;&#x6362;&#x4E3B;&#x9898;"><a name="&#x76AE;&#x80A4;&#x66F4;&#x6362;-&#x3001;&#x66F4;&#x6362;&#x4E3B;&#x9898;" class="anchor-navigation-ex-anchor" href="#&#x76AE;&#x80A4;&#x66F4;&#x6362;-&#x3001;&#x66F4;&#x6362;&#x4E3B;&#x9898;"><i class="fa fa-link" aria-hidden="true"></i></a>2. &#x76AE;&#x80A4;&#x66F4;&#x6362; &#x3001;&#x66F4;&#x6362;&#x4E3B;&#x9898;</h1>
<h2 id="&#x66F4;&#x6362;&#x76AE;&#x80A4;&#x6838;&#x5FC3;&#x539F;&#x7406;"><a name="&#x66F4;&#x6362;&#x76AE;&#x80A4;&#x6838;&#x5FC3;&#x539F;&#x7406;" class="anchor-navigation-ex-anchor" href="#&#x66F4;&#x6362;&#x76AE;&#x80A4;&#x6838;&#x5FC3;&#x539F;&#x7406;"><i class="fa fa-link" aria-hidden="true"></i></a>2.1. &#x66F4;&#x6362;&#x76AE;&#x80A4;&#x6838;&#x5FC3;&#x539F;&#x7406;</h2>
<pre><code class="lang-text">&#x91CD;&#x5199; LayoutInflater.Factory &#x63A5;&#x53E3; View onCreateView(String name, Context context, AttributeSet attrs)  
&#x81EA;&#x5B9A;&#x4E49; xml&#x4E2D; view&#x89E3;&#x6790;&#x7684;&#x8FC7;&#x7A0B;&#xFF0C;&#x5E76;&#x5C06;&#x89E3;&#x6790;&#x51FA;&#x6765;&#x7684;&#x5C5E;&#x6027;&#x548C;view&#x4FDD;&#x5B58;&#x8D77;&#x6765;
&#x6362;&#x80A4;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x904D;&#x5386;&#x8FD9;&#x4E9B;&#x5C5E;&#x6027;&#x548C;&#x63A7;&#x4EF6;&#xFF0C;
&#x91CD;&#x65B0;&#x8BBE;&#x7F6E;&#x6B64;view&#x7684;&#x6362;&#x80A4;&#x5C5E;&#x6027;&#x5BF9;&#x5E94;&#x7684;&#x8D44;&#x6E90;&#x3002;

mSkinFactory = new MySkinFactory();
getLayoutInflater().setFactory(mSkinFactory);

&#x5982;&#x679C;&#x662F;&#x8BBE;&#x7F6E;&#x9ED8;&#x8BA4;&#x4E3B;&#x9898;&#x76AE;&#x80A4;&#x5C31;&#x662F;&#x4ECE;&#x5F53;&#x524D;&#x7684;apk&#x5305;&#x4E2D;&#x83B7;&#x53D6;&#x8D44;&#x6E90;id
int originColor = context.getResources().getColor(resId);
&#x5982;&#x679C;&#x662F;&#x5207;&#x6362;&#x76AE;&#x80A4;&#x5305;&#xFF0C;&#x5C31;&#x4ECE;&#x76AE;&#x80A4;&#x5305;&#x4E2D;&#x52A0;&#x8F7D;&#x8D44;&#x6E90;id
int newResId = mSkinResources.getIdentifier(resName, &quot;color&quot;, skinPackageName);

&#x6CE8;&#xFF1A;&#x76AE;&#x80A4;&#x5305;&#x7684;&#x672C;&#x8D28;&#x5C31;&#x662F;&#x4E00;&#x4E2A;apk&#xFF0C;&#x91CC;&#x9762;&#x914D;&#x7F6E;&#x7684;&#x8D44;&#x6E90;&#x540D;&#x5B57;&#x8DDF;&#x4E3B;apk&#x4E2D;&#x7684;&#x8D44;&#x6E90;&#x540D;&#x5B57;&#x662F;&#x4E00;&#x6837;&#x7684;
</code></pre>
<h2 id="&#x6697;&#x9ED1;&#x6A21;&#x5F0F;&#x7701;&#x7535;&#x539F;&#x7406;"><a name="&#x6697;&#x9ED1;&#x6A21;&#x5F0F;&#x7701;&#x7535;&#x539F;&#x7406;" class="anchor-navigation-ex-anchor" href="#&#x6697;&#x9ED1;&#x6A21;&#x5F0F;&#x7701;&#x7535;&#x539F;&#x7406;"><i class="fa fa-link" aria-hidden="true"></i></a>2.2. &#x6697;&#x9ED1;&#x6A21;&#x5F0F;&#x7701;&#x7535;&#x539F;&#x7406;</h2>
<pre><code class="lang-text">&#x76EE;&#x524D;&#x4E3B;&#x6D41;&#x7684;&#x624B;&#x673A;&#x5C4F;&#x5E55;&#x6709; LCD (&#x6DB2;&#x6676;) &#x3001;OLED (&#x6709;&#x673A;&#x53D1;&#x5149;&#x4E8C;&#x6781;&#x7BA1;) &#x5C4F;&#x5E55;&#x3002;

LCD &#x5C4F;&#x5E55;&#x80CC;&#x5149;&#x59CB;&#x7EC8;&#x88AB;&#x70B9;&#x4EAE;&#xFF0C;&#x65E0;&#x8BBA;&#x50CF;&#x7D20;&#x663E;&#x793A;&#x7684;&#x662F;&#x9ED1;&#x8272;&#x8FD8;&#x662F;&#x5176;&#x4ED6;&#x989C;&#x8272;&#xFF0C;&#x90FD;&#x4F1A;&#x6D88;&#x8017;&#x76F8;&#x540C;&#x7684;&#x80FD;&#x91CF;&#x3002;
&#x65E9;&#x671F;&#x624B;&#x673A;&#x5C4F;&#x5E55;&#x57FA;&#x672C;&#x4E0A;&#x90FD;&#x662F; LCD &#x3002;

OLED &#x5C4F;&#x5E55;&#x50CF;&#x7D20;&#x70B9;&#x662F;&#x5355;&#x72EC;&#x5DE5;&#x4F5C;&#x7684;&#xFF0C;&#x5F53;&#x50CF;&#x7D20;&#x70B9;&#x662F;&#x7EAF;&#x9ED1;&#x8272;&#x65F6;&#xFF0C;&#x8BE5;&#x50CF;&#x7D20;&#x4F1A;&#x88AB;&#x5173;&#x95ED;&#xFF0C;&#x4E0D;&#x6D88;&#x8017;&#x80FD;&#x91CF;&#x3002;
OLED &#x6280;&#x672F;&#x4E0D;&#x9700;&#x8981;&#x80CC;&#x5149;&#x7684;&#x652F;&#x6301;&#xFF0C;&#x7701;&#x53BB;&#x4E86;&#x6DB2;&#x6676;&#x548C;&#x80CC;&#x5149;&#x6A21;&#x7EC4;&#xFF0C;&#x7ED3;&#x6784;&#x975E;&#x5E38;&#x7B80;&#x5355;&#xFF0C;&#x673A;&#x8EAB;&#x81EA;&#x7136;&#x4E5F;&#x53EF;&#x4EE5;&#x8FBE;&#x5230;&#x6781;&#x81F4;&#x8D85;&#x8584;&#x3002;

&#x6240;&#x4EE5; &#x53EA;&#x6709; OLED&#x5C4F;&#x5E55;&#x5728;&#x6697;&#x9ED1;&#x6A21;&#x5F0F;&#x4E0B;&#x7701;&#x7535;&#x3002;

android APP &#x53EF;&#x4EE5;&#x81EA;&#x5DF1;&#x8BBE;&#x7F6E;&#x6697;&#x9ED1;&#x4E3B;&#x9898;&#x76AE;&#x80A4;&#x5305;&#xFF0C;
&#x4E5F;&#x53EF;&#x4EE5;&#x7B80;&#x5355;&#x914D;&#x7F6E;&#x4E00;&#x4E0B;&#xFF0C;&#x4F7F;&#x7528;&#x7CFB;&#x7EDF;&#x7684;&#x6697;&#x9ED1;&#x4E3B;&#x9898;&#x3002;
Android 10 &#x5F00;&#x59CB;&#x4ECE;&#x7CFB;&#x7EDF;&#x5C42;&#x9762;&#x652F;&#x6301;&#x6697;&#x9ED1;&#x4E3B;&#x9898;&#x3002;
</code></pre>
<h2 id="&#x6362;&#x80A4;demo"><a name="&#x6362;&#x80A4;demo" class="anchor-navigation-ex-anchor" href="#&#x6362;&#x80A4;demo"><i class="fa fa-link" aria-hidden="true"></i></a>2.3. &#x6362;&#x80A4;demo</h2>
<pre><code class="lang-text">https://github.com/hnyer/XSkinLoader ,
&#x5728;&#x201C;&#x53F2;&#x6D77;&#x94A9;&#x6C89;&#x201D;APP&#x4E2D;&#x6709;&#x5B9E;&#x9645;&#x6D4B;&#x8BD5;&#x3002;
</code></pre>
<footer class="page-footer"><span class="copyright">( no Copyright&#xFF0C;enjoy youself ! ) all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">The file was updated at :
2022-04-04 10:49:02
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="开源软件.html" class="navigation navigation-prev " aria-label="Previous page: 开源软件和框架">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../源码阅读/源码阅读配置.html" class="navigation navigation-next " aria-label="Next page: 源码阅读">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Android常用代码","level":"1.6","depth":1,"next":{"title":"源码阅读","level":"1.7","depth":1,"path":"chinese/源码阅读/源码阅读配置.md","ref":"chinese/源码阅读/源码阅读配置.md","articles":[{"title":"其他框架源码","level":"1.7.1","depth":2,"path":"chinese/源码阅读/其他框架源码.md","ref":"chinese/源码阅读/其他框架源码.md","articles":[]}]},"previous":{"title":"开源软件和框架","level":"1.5","depth":1,"path":"chinese/doc/开源软件.md","ref":"chinese/doc/开源软件.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-plus","todo","anchor-navigation-ex","copy-code-button","fontsettings","tbfed-pagefooter","local-video","splitter","expandable-chapters","favicon","theme-comscore","local-video"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"( no Copyright，enjoy youself ! )","modify_label":"The file was updated at :","modify_format":"YYYY-MM-DD HH:mm:ss"},"todo":{},"splitter":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"family":"sans","size":2,"theme":"white"},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":{"shortcut":"assets/images/favicon.ico","bookmark":"assets/images/favicon.ico"},"theme-comscore":{},"local-video":{},"copy-code-button":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"Aivin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Aivin开发笔记","language":"zh-hans","gitbook":"*","description":"Aivin开发笔记"},"file":{"path":"chinese/doc/Android常用代码.md","mtime":"2022-04-04T02:49:02.757Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-04-04T03:47:09.782Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

